Getting Started with Google Cloud Compute Engine and Docker

Asif Shaikh
Cloudnloud Tech Community
4 min readSep 23, 2023
Google Cloud Compute Engine and Docker

In this article, we will walk you through the process of setting up a virtual machine (VM) on Google Cloud Compute Engine and installing Docker to run your containers. Whether you’re a seasoned developer or just getting started with cloud computing, this guide will help you get up and running in no time.

Creating a Google Cloud VM

Log in to Google Cloud Console:

  • Start by logging in to your Google Cloud Console account.

Navigate to Compute Engine:

  • Click on the hamburger icon in the top-left corner.
  • Select “Compute Engine” from the menu.
  • Choose “VM instances” from the submenu.

Create a New VM:

  • Click the “Create” button to create a new VM instance.
  • Give your VM a name for easy identification.

Select Region and Zone:

  • Choose the region and zone that best suits your requirements.

Machine Configuration:

  • Select the machine series; for example, we’ll choose “E2” with 2 vCPUs and 4GB memory.
  • Scroll down to “Boot disk” and click “Change.” We’ll use Ubuntu 20.04 LTS with a 20GB balanced persistent disk. Click “Select.”

Access Scopes and Firewall Rules:

  • Configure access scopes; you can allow full access to all Cloud APIs or set access for each API individually.
  • Optionally, set up firewall rules to control network traffic.

Review and Create:

  • Review the monthly cost estimate of your VM on the right side.
  • Click “Create” to start provisioning your VM.

Monitor VM Creation:

  • Wait for your VM to be created. You can monitor its status in the console.

SSH Connect:

  • Once your VM is up and running, click the “SSH” button to connect to it.
  • Click “Authorize” to establish the connection.

Installing Docker

Before installing Docker, ensure that any previous installations are removed:

sudo apt-get update
sudo apt install gnome-terminal # For non-Gnome Desktop environments
sudo apt remove docker-desktop # Remove previous Docker versions (if installed)

Now, you can install Docker using the official script:

curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh ./get-docker.sh

Dcoker Repo script from docker official page.

Ignore any warning messages that may appear during installation.

Verify Docker Installation

To verify that Docker is installed successfully, run:

sudo docker version

Run Your First Docker Container

Let’s have some fun by running a simple Docker container:

sudo docker run docker/whalesay cowsay Hello-Asif

This command will run a Docker image where a whale says “Hello-Asif.” You can find the image on Docker Hub here.

To see the available images on your local system, run:

sudo docker images

And that’s it! You’ve successfully set up a Google Cloud VM and installed Docker. You’re now ready to explore the world of containerization and cloud computing. Happy coding!

Thank you for reading, and if you have any questions or need further assistance, feel free to ask.

--

--