Pages

Pages

Tuesday, 7 July 2015

Setting up Docker on Google Container Engine

I am going to help guide and make sure that you have your environment and your settings all correct so that we can create a Docker Host on a Google Container Engine. If you do not know what a Docker Host is then you should do yourself a favour and go to the Docker website and see how they are taking over the world!!! But seriously, have a look, it is a very impressive virtualisation (or containerisation??) tool!

Environment Setup

This tutorial follows on from the Setting up Google Container Engine on Mac and I will assume you have done everything in that post regarding getting your environment setup. Please make sure you have done everything as explained.

Creating a Docker Host

In this tutorial we are going to be creating the docker host instance from the command line. So follow the steps below to get your first docker host instance up and running:

  • Open up your terminal and make sure that the gcloud sdk is installed.
  • Type the following command to link the sdk to the project where you will be creating the vm instance:
    gcloud config set project "google-cloud-project-id"
    where "google-cloud-project-id" is the name of your project
  • Run the following code to create the Docker host instance with the instance name "docker-instance-01":
    gcloud compute instances create "docker-instance-01" \
      --image "container-vm" \
      --zone "us-central1-a" \
      --machine-type "f1-micro"
    where "docker-instance-01" is the name of your instance container
  • Now that the instance is created, you can SSH into the machine using the following code:
    gcloud compute ssh --zone "us-central1-a" "docker-instance-01"
  • You should now have access to your first hosted docker host!

Docker "Hello World"

You can run the docker hello-world container to verify that the instance is running the docker container software:
  • Run the following command while SSH'ed into the instance you just created:
    sudo docker run hello-world
  • You should then see this message print on your screen:
    Hello from Docker. This message shows that your installation appears to be working correctly.
You now have a fully hosted Docker instance running on your Google Container Engine!!! I will have more tutorials in the future with things that you can do inside of docker!

No comments:

Post a Comment