Google Cloud Compute Engine

Set up Docker on Ubuntu 18.04 LTS

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

Set up Docker on Ubuntu 18.04 LTS. In this guide you are going to install Docker Community Edition (CE) on Ubuntu 18.04.

This setup is tested on Google Compute Engine VM Instance (Micro) with 600 MB Ram, 10 GB Disk space on Ubuntu. This set up will work on Ubuntu 16.04, 17.04, Debian.


  1. Your Compute Engine Instance running.
  2. For setting up Compute Engine, see the Setting up Compute Engine Instance.
  3. Basic Ubuntu server set up on Google Cloud Platform

Install Docker

Make sure you install the latest version of Docker from the official Docker repository. The official Ubuntu repository also has the Docker installation package, but it may not be the latest version.

Let’s start installing Docker.

sudo apt update
sudo apt install apt-transport-https ca-certificates curl software-properties-common
curl -fsSL | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] bionic stable"
sudo apt update

Make sure you are going to install Docker from official Docker repo.

sudo apt-cache policy docker-ce

You will receive an output similar to this.

Installed: (none)
Candidate: 5:18.09.1~3-0~ubuntu-bionic
Version table:
5:18.09.1~3-0~ubuntu-bionic 500
500 bionic/stable amd64 Packages
5:18.09.0~3-0~ubuntu-bionic 500
500 bionic/stable amd64 Packages
18.06.1~ce~3-0~ubuntu 500
500 bionic/stable amd64 Packages
18.06.0~ce~3-0~ubuntu 500
500 bionic/stable amd64 Packages
18.03.1~ce~3-0~ubuntu 500
500 bionic/stable amd64 Packages

Now docker-ce is not installed and the installation candidate is from the official repository.

sudo apt install docker-ce

Now Docker Community Edition will get installed and the process is enabled to start on boot.

Check the status of Docker.

sudo systemctl status docker

The output will be like this.

● docker.service - Docker Application Container Engine
Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)
Active: active (running) since Wed 2019-01-16 05:15:32 UTC; 37s ago
Main PID: 4665 (dockerd)
Tasks: 8
CGroup: /system.slice/docker.service
└─4665 /usr/bin/dockerd -H fd://

Run Docker Command Without Sudo

The docker command can only be executed as root user by default. If you need to run the docker command without sudo, you need to add your username to the docker group.

sudo usermod -aG docker username

Now restart your SSH or open a new terminal to see the changes.

From now you use the docker command without sudo.

Using Docker Commands

To view the system information about Docker.

docker info

Download Docker Images

docker run hello-world

If the output you get is similar to the below then you can access and download images from Docker Hub.

Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
1b930d010525: Pull complete
Digest: sha256:2557e3c07ed1e38f26e389462d03ed943586f744621577a99efb77324b0fe535
Status: Downloaded newer image for hello-world:latest

Hello from Docker!
This message shows that your installation appears to be working correctly.

Run the below command to see downloaded images.

docker images
hello-world latest fce289e99eb9 2 weeks ago 1.84kB

Manage Docker Containers

Once you have started using Docker you will have many active and inactive containers.

To view all active containers, use the following command.

docker ps

To view all containers which are active and inactive, use the below command.

docker ps -a
11ecffffb6a9 hello-world "/hello" 2 minutes ago Exited (0) 2 minutes ago boring_feistel

To view the latest container

docker ps -l

To start a docker container, use docker start command followed by the Container ID or Container Name.

docker start 11ecffffb6a9


 docker start boring_feistel 

Likewise to stop a running container you can use the docker stop command followed by Container ID or Container Name.

docker stop 11ecffffb6a9


 docker stop boring_feistel 

If you no longer need the container you can remove the container with the docker rm followed by Container ID or Container Name.

For more details about docker commands use the docker run help command.

These the steps to install Docker on Ubuntu 18.04 and use the commands to manage the containers, images, etc.

Write A Comment

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