Docker is a containerization technology that allows you to quickly build, test, and deploy applications as portable, self-sufficient containers that can run virtually anywhere. Docker has become the de facto standard for container deployment, and it is an essential tool for DevOps engineers and their continuous integration and delivery pipeline

In this post, we’ll cover how to install Docker on an Ubuntu 18.04 machine

First I log to my machine :

$ sudo apt update


$ sudo apt install apt-transport-https ca-certificates curl gnupg-agent software-properties-common


$ curl -fsSL | sudo apt-key add -


$ sudo add-apt-repository "deb [arch=amd64] $(lsb_release -cs) stable"


Now that the Docker repository is enabled, you can install any Docker version you need

# to look docker versions
$ apt list -a docker-ce


$ sudo apt update


$ sudo apt install docker-ce


$ sudo systemctl status docker


# Executing docker command without sudo

$ sudo usermod -aG docker ${USER}

Docker Command-Line Interface

The Docker CLI command takes this form:

$ docker [option] [subcommand] [arguments]


Run the following command to take a look at the container image it pulled from Docker Hub:

This is the image pulled from the Docker Hub public registry. The Image ID is in SHA256 hash format—this field specifies the Docker image that's been provisioned. When the docker daemon can't find an image locally, it will by default search the public registry for the image.

# Search Docker Image
$ docker search ubuntu
# Download Docker Image
$ docker image pull ubuntu
# To list all downloaded images type:
$ docker image ls
# Start Docker Container
$ docker container run hello-world


This simple container returns Hello from Docker! to your screen. While the command is simple, notice in the output the number of steps it performed. The docker daemon searched for the hello-world image, didn't find the image locally, pulled the image from a public registry called Docker Hub, created a container from that image, and ran the container for you.

# The switch -it allows us to interact with the container via the command line. To start an interactive container type:
$ docker container run -it ubuntu /bin/bash


# Remove Docker Image
$ docker image ls
# Use images ls or Run the following command to take a look at the container image it pulled from Docker Hub:
$ docker images
$ docker image rm ubuntu
$ docker image ls



# List Docker Containers
# Look at the running containers by running the following command
$ docker container ls
# To view both active and inactive
$ docker container ls -a
# To delete one or more containers copy the container ID
# Exemple ID=f0b8e3deec3c for ubuntu container
$ docker container rm f0b8e3deec3c
$ docker container ls -a


You can uninstall Docker as any other package installed with apt

$ sudo apt purge docker-ce
$ sudo apt autoremove

Docker Compose

Docker Compose is a tool that allows you to define and manage multi-container Docker applications. It uses a YAML file to configure the application’s services, networks, and volumes.

The Docker Compose installation package is available in the official Ubuntu 18.04 repositories but it may not always be the latest version. The recommended approach is to install Docker Compose from the Docker’s GitHub repository.

To install Docker Compose on Ubuntu 18.04, follow these steps:

$ sudo curl -L "$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose


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


Verify the installation by running the following command which will display the Compose version:

$ docker-compose --version


You can uninstall Docker Compose  with  simply remove the binary by typing:

$ sudo rm /usr/local/bin/docker-compose
Learn more about Docker in the  official documentation

Enjoy! 😎