Docker’s popularity has increased rapidly over the past years, and it has evolved traditional software development. Docker’s containers allow for the immense economy of scale and have made development scalable, while at the same time keeping the process user-friendly. Our Docker tutorial will help you understand Docker containers, and its benefits, and will also help learn the ways to build docker environment and docker commands. So start learning now to know everything about docker – from its advantages to how it is different from other virtual machines, know how to install it and master several docker technologies.
Red Hat Enterprise Linux (RHEL) and CentOS
Docker runs on RHEL 7 and CentOS 7.
Install Docker
Install with Yum
- Log into your system as a user with
sudo
privileges. - Update your system:
sudo yum update -y
. - Add the yum repo (use the code below for both RHEL 7 and CentOS 7):
$ sudo tee /etc/yum.repos.d/docker.repo <<-'EOF' [dockerrepo] name=Docker Repository baseurl=https://yum.dockerproject.org/repo/main/centos/7/ enabled=1 gpgcheck=1 gpgkey=https://yum.dockerproject.org/gpg EOF
- Install Docker:
sudo yum install docker-engine -y
- Start Docker:
sudo service docker start
- Verify Docker:
sudo docker run hello-world
Install with the Docker Installation Script
- Log into your system as a user with
sudo
privileges. - Update your system:
sudo yum update -y
- Run Docker’s installation script:
curl -fsSL https://get.docker.com | sh;
This script adds thedocker.repo
repository and installs Docker. - Start Docker:
sudo service docker start
- Verify Docker:
sudo docker run hello-world
The Docker Group
If you prefer, you can set up a docker
group to run Docker (instead of root
). However, as docker
must have sudo
access, docker
receives the same access as root
.
- Run the following command to create a Docker group and add your user to the group (replace USERNAME with your username):
sudo groupadd docker && sudo usermod -aG docker USERNAME
- Log out and back in.
- Verify Docker works without
sudo
:docker run hello-world
Start Docker at Boot
Run one of the following:
sudo chkconfig docker on
sudo systemctl enable docker
How To Install Docker on Ubuntu
Steps for Installing Docker:
- Open the terminal on Ubuntu.
-
Remove any Docker files that are running in the system, using the following command:
$ sudo apt-get remove docker docker-engine docker.io
After entering the above command, you will need to enter the password of the root and press enter.
- Check if the system is up-to-date using the following command:
$ sudo apt-get update
- Install Docker using the following command:
$ sudo apt install docker.io
You’ll then get a prompt asking you to choose between y/n – choose y
- Install all the dependency packages using the following command:
$ sudo snap install docker
- Before testing Docker, check the version installed using the following command:
$ docker --version
- Pull an image from the Docker hub using the following command:
$ sudo docker run hello-world
Here, hello-world is the docker image present on the Docker hub.
- Check if the docker image has been pulled and is present in your system using the following command:
$ sudo docker images
- To display all the containers pulled, use the following command:
$ sudo docker ps -a
- To check for containers in a running state, use the following command:
$ sudo docker ps
You’ve just successfully installed Docker on Ubuntu!
Reference
https://docs.docker.com/engine/install/
https://www.simplilearn.com/tutorials/docker-tutorial
https://runnable.com/docker/install-docker-on-linux