Install Docker on Ubuntu 16.04

In this tutorial we are going to learn how to install Docker on Ubuntu 16.04. Docker is container platform that provides an isolated environment for applications and separate application from the operating system using containers.

For this tutorial I will use Ubuntu Server 16.04.

To install docker on Ubuntu 16.04, First update the apt source list.

apt-get update

Then, Install Ubuntu docker.io package with apt-get command.

apt-get install docker.io

To verify the docker installation, run the docker version command.

docker version

You should see the output something like the following:

Install Docker on Ubuntu 16.04

To view the status of the Ubuntu Docker Engine, Type:

systemctl status docker.service

Example, Run Docker Containers on Ubuntu Linux

To run docker containers we need images. For example, To run nginx on Docker we need to get nginx image.

We can download images with docker pull command.

docker pull nginx:latest

Then, we start a new nginx container using the nginx image we downloaded.

docker run -d --name ubuntu-nginx -p 80:80 nginx:latest

In the above example, we started new container called ubuntu-nginx. We also mapped port 80 of the host machine to port 80 of the ubuntu-nginx container.

List Running Docker Containers

To get a list of running containers on your Ubuntu 16.04 Server, Type:

docker ps

To view all containers (Both running and stopped), Type:

docker ps -a

To find docker images you can use docker search command or you can go to the Docker Hub Web Page.