How to install and use docker on Ubuntu 16.04 system??
Docker is an application which runs applications within a container. In this article, you will get to know how to install docker on ubuntu 16.04 systems.
1. One Ubuntu 16.04 server set-up with sudo user access.
Read More: Install Docker and Manage on Ubuntu 18.04 system
Step 1: Remove Default Docker Packages
The first step is to remove the default docker packages from the ubuntu 16.04 system.
sudo apt-get purge docker docker-engine lxc-docker docker.io
Now install the required packages for the docker. Run the following command.
sudo apt-get install curl apt-transport-https ca-certificates software-properties-common
Step 2: Add Docker Repository
Add the GPG key to ensure download packages are valid. For this, execute the below command.
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add
After that, now add the docker repository to the ubuntu 16.04 system.
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
Step 3: Install Docker on Ubuntu
Finally, let’s start the docker installation on the ubuntu 16.04 system. We will instal the docker community edition. Run the following command.
sudo apt-get update sudo apt-get install docker-ce
After successful installation of docker, docker service will start automatically. You can also check the docker service status using the following command.
sudo systemctl status docker
Step 4: How to Use a Docker on Ubuntu
To run a docker, sudo privileged is needed.
Note: it can also be run by adding a user to the docker group. Docker group is automatically created during the Docker installation.
How To Search Docker Images
By default, docker hub is used to search the images. For example, to search a ubuntu image execute the following command.
docker search ubuntu
How To Download Docker Images
To download the docker images, pull sub-command is used. As shown in the below screenshot.
docker pull ubuntu
To check the downloaded images on the ubuntu system, run the following command.
Run Docker Container with Image
Ubuntu image is downloaded. Now it’s time to launch a docker container. Execute the below command.
docker run -it ubuntu
where -it = gives you interactive shell access.
Type Ctrl + P + Q to exit from the docker container. But it will leave container running in the background. To stop docker container type exit in the terminal.
To check all the running docker container, execute the following command.
If you want to check all the running or stopped containers, run the below command with switch ‘a’
docker ps -a
Step 5: To start/Stop Docker Container
Run the following command to start the docker container.
docker start <container-id>
Container id = command docker ps gives you container id or name.
Execute the below command to stop a container.
docker stop <container-id>
Conclusion: You have perfectly learned how to install docker on Ubuntu 16.04 systems. In case of any doubts or feedback, kindly use the below comment box.