Google Cloud Compute Engine

Running Docker Compose with Docker on Ubuntu 18.04 – Google Cloud

Disclosure: This post may contain affiliate links, which means we may receive a commission if you click a link and purchase something that we recommended.

Pinterest LinkedIn Tumblr

Running Docker Compose with Docker on Ubuntu 18.04 – Google Cloud. Docker Compose provides an easy way to orchestrate the processes of Docker containers.

This guide helps you to install Docker Compose for managing multi-container applications.


  1. Your Compute Engine Instance running.
  2. For setting up Compute Engine, see the Setting up Compute Engine Instance.
  3. Ubuntu server setup on Google Cloud.
  4. How to install Docker on Ubuntu 18.04 LTS.

Install Docker Compose

We shall install latest version of Docker Compose from the GitHub repository.

sudo curl -L`uname -s`-`uname -m` -o /usr/local/bin/docker-compose

Set correct permissions.

sudo chmod +x /usr/local/bin/docker-compose

Test the installation

docker-compose --version
docker-compose version 1.23.2, build 1110ad01

Now Docker Compose is installed successfully and you can start running containers.

Use Docker Compose

Docker Compose allows you to use YAML file to define multiple container applications. With the YAML file you can run, build and configure all containers.

Create a project directory and navigate inside that directory.

mkdir my-project
cd my-project

Create a YAML file. This is a basic example of the yaml file for hello world .

sudo nano docker-compose.yml

Paste the following contents and save the file.

image: hello-world

Hit Ctrl + X followed by Y and Enter to save the file and exit.

Now you can execute the following command to pull the hello word image from Docker Hub.

docker-compose up

You will receive an output similar to this.

Pulling my-test (hello-world:)…
latest: Pulling from library/hello-world
1b930d010525: Pull complete
Creating my-project_my-test_1 … done
Attaching to my-project_my-test_1
my-test_1 |
my-test_1 | Hello from Docker!
my-test_1 | This message shows that your installation appears to be working correctly.
my-test_1 |
my-test_1 | To generate this message, Docker took the following steps:
my-test_1 | 1. The Docker client contacted the Docker daemon.
my-test_1 | 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
my-test_1 | (amd64)
my-test_1 | 3. The Docker daemon created a new container from that image which runs the
my-test_1 | executable that produces the output you are currently reading.
my-test_1 | 4. The Docker daemon streamed that output to the Docker client, which sent it
my-test_1 | to your terminal.
my-test_1 |
my-test_1 | To try something more ambitious, you can run an Ubuntu container with:
my-test_1 | $ docker run -it ubuntu bash
my-test_1 |
my-test_1 | Share images, automate workflows, and more with a free Docker ID:
my-test_1 |
my-test_1 |
my-test_1 | For more examples and ideas, visit:
my-test_1 |
my-test_1 |
my-project_my-test_1 exited with code 0

Now the hello-world image is pulled from Docker Hub and docker-compose creates a container, attaches and runs the program.

You can see all the containers using the following command.

docker ps -a
f697e5990246 hello-world "/hello" 43 seconds ago Exited (0) 41 seconds ago my-project_my-test_1

Alright, Done! Now you have installed Docker Compose in your Ubuntu Server.

Write A Comment

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.