How to install Docker in Centos 7
Date Posted : 20/12/2018
How to install Docker in Centos 7
Docker is a most handy DevOps tool used nowadays. In this post, we will explain Docker-CE installation and uninstallation steps.
Prerequisites
OS requirements
To install Docker CE, you need to maintained version of CentOS 7. Therefore, archived versions aren’t supported or tested.
Uninstall old versions
Older versions of Docker were called docker
or docker-engine
. If these are installed, uninstall them, along with associated dependencies.
# yum remove docker \
docker-client \
docker-client-latest \
docker-common \
docker-latest \
docker-latest-logrotate \
docker-logrotate \
docker-selinux \
docker-engine-selinux \
docker-engine
It’s OK if yum
reports that none of these packages are installed.
The contents of /var/lib/docker/
, including images, containers, volumes, and networks, are preserved. The Docker CE package is now called docker-ce
.
Install Docker CE
Step by step procedure, to install your Docker CE on your VM
STEP 1: SET UP THE REPOSITORY
Install required packages. yum-utils
provides the yum-config-manager
utility,
# yum install -y yum-utils \
device-mapper-persistent-data \
lvm2
Use the following command to set up the stable repository. You always need the stable repository,
# yum-config-manager \
--add-repo \
https://download.docker.com/linux/centos/docker-ce.repo
STEP 2: Install the latest version of Docker CE .
# yum install docker-ce
If prompted to accept the GPG key, verify that the fingerprint matches060A 61C5 1B55 8A7F 742B 77AA C52F EB6B 621E 9F35
, and if so, accept it.
STEP 3:
If you have multiple Docker repositories enabled, installing or updating without specifying a version in the yum install or yum update command always installs the highest possible version, which may not be appropriate for your stability needs.
STEP 4 : To install a specific version of Docker CE,
# yum list docker-ce --showduplicates | sort -r
docker-ce.x86_64 18.09.0.ce-1.el7.centos docker-ce-stable
STEP 5 : start docker
# systemctl start docker
STEP 6 : Verify docker
Verify that docker is installed correctly by running the hello-world image.
# docker run hello-world
STEP 7 : Enable docker
By enabling docker , it will run ,even after the reboot of VM.
# systemctl Enable docker
Docker Installation is completed successfully.
Uninstall Docker CE
Uninstall the Docker package:
# yum remove docker-ce
To delete all images, containers, and volumes:
Note : You must delete any edited configuration files manually.
# sudo rm -rf /var/lib/docker
We hope that you have understand the setup. It is pretty easy and if you have any query/concerns ,please comment below, we will answer your queries.
1 thought on “How to install Docker in Centos 7”