How to install and configure Docker on RHEL or CentOS 7 ?
How to install and configure Docker on RHEL or CentOS 7 ?
Step 1. Install the required packages. yum-utils provides the yum-config-manager utility, and device-mapper-persistent-data and lvm2 are required by the device-mapper storage driver.
Verify if centos "extras" repository is enabled in "/etc/yum.repos.d/CentOS-Base.repo", bydefault it would be enabled:
[extras]
name=CentOS-$releasever - Extras
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras&infra=$infra
#baseurl=http://mirror.centos.org/centos/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
NOTE: If installing on RHEL 7.5 or ater version, please mount RHEL 7.6 or later ISO to /mnt and add local repository for yum, note that RHEL 7.6 iso is needed to update few of the packages and dependencies as 7.5 ISO has old version of packages which are not compatible to the latest docker releases.
[root@localhost ~]# yum install -y yum-utils device-mapper-persistent-data lvm2
Add docker repository, so that docker can be installed with its dependencies:
[root@localhost ~]# yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
Note: This will download and add "/etc/yum.repos.d/docker-ce.repo" file.
[root@localhost ~]# yum update
[root@localhost ~]# yum install docker-ce docker-ce-cli containerd.io
OR
In case if you manually want to download and install "docker-ce, docker-ce-cli, containerd.io" rpm's those RPM packages are available at:
In case if you manually want to download and install "docker-ce, docker-ce-cli, containerd.io" rpm's those RPM packages are available at:
2. https://download.docker.com/linux/centos/7/x86_64/stable/Packages/docker-ce-18.09.5-3.el7.x86_64.rpm
(ERROR IN RHEL 7) : In case during "yum install docker-ce" you are observing below error:
[root@localhost ~]# yum install docker-ce docker-ce-cli containerd.io
Loaded plugins: langpacks, product-id, search-disabled-repos, subscription-manager
This system is not registered with an entitlement server. You can use subscription-manager to register.
Resolving Dependencies
--> Running transaction check
---> Package containerd.io.x86_64 0:1.2.5-3.1.el7 will be installed
---> Package docker-ce.x86_64 3:18.09.6-3.el7 will be installed
--> Processing Dependency: container-selinux >= 2.9 for package: 3:docker-ce-18.09.6-3.el7.x86_64
---> Package docker-ce-cli.x86_64 1:18.09.6-3.el7 will be installed
--> Finished Dependency Resolution
Error: Package: 3:docker-ce-18.09.6-3.el7.x86_64 (docker-ce-stable)
Requires: container-selinux >= 2.9
You could try using --skip-broken to work around the problem
You could try running: rpm -Va --nofiles --nodigest
then install "container-selinux" rpm first:
[root@localhost ~]# yum install http://vault.centos.org/centos/7.3.1611/extras/x86_64/Packages/container-selinux-2.9-4.el7.noarch.rpm
Then again try to install docker:
[root@localhost ~]# yum install docker-ce
Step 2. Start Docker daemon:
[root@localhost ~]# systemctl start docker
[root@localhost ~]# systemctl status docker
● docker.service - Docker Application Container Engine
Loaded: loaded (/usr/lib/systemd/system/docker.service; disabled; vendor preset: disabled)
Active: active (running) since Fri 2019-03-29 20:56:16 IST; 10s ago
Docs: https://docs.docker.com
Main PID: 77237 (dockerd)
Tasks: 13
Memory: 36.0M
CGroup: /system.slice/docker.service
└─77237 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
Mar 29 20:56:11 localhost.localdomain dockerd[77237]: time="2019-03-29T20:56:11.297944396+05:30" level=i...rpc
Mar 29 20:56:11 localhost.localdomain dockerd[77237]: time="2019-03-29T20:56:11.298059662+05:30" level=i...rpc
Mar 29 20:56:11 localhost.localdomain dockerd[77237]: time="2019-03-29T20:56:11.370193837+05:30" level=i...ds"
Mar 29 20:56:11 localhost.localdomain dockerd[77237]: time="2019-03-29T20:56:11.443415096+05:30" level=i...t."
Mar 29 20:56:13 localhost.localdomain dockerd[77237]: time="2019-03-29T20:56:13.734544797+05:30" level=i...ss"
Mar 29 20:56:16 localhost.localdomain dockerd[77237]: time="2019-03-29T20:56:16.427547518+05:30" level=i...e."
Mar 29 20:56:16 localhost.localdomain dockerd[77237]: time="2019-03-29T20:56:16.522272850+05:30" level=i...9.5
Mar 29 20:56:16 localhost.localdomain dockerd[77237]: time="2019-03-29T20:56:16.522575499+05:30" level=i...on"
Mar 29 20:56:16 localhost.localdomain systemd[1]: Started Docker Application Container Engine.
Mar 29 20:56:16 localhost.localdomain dockerd[77237]: time="2019-03-29T20:56:16.538844946+05:30" level=i...ck"
Hint: Some lines were ellipsized, use -l to show in full.
The docker daemon is up and running, now lets make it persistent across reboot:
[root@localhost ~]# systemctl enable docker
Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service.
To check if docker is installed and configured properly run:
[root@localhost ~]# docker info
Containers: 0
Running: 0
Paused: 0
Stopped: 0
Images: 0
Server Version: 18.09.5
Storage Driver: overlay2
Backing Filesystem: xfs
Supports d_type: true
Native Overlay Diff: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
Volume: local
Network: bridge host macvlan null overlay
Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: bb71b10fd8f58240ca47fbb579b9d1028eea7c84
runc version: 2b18fe1d885ee5083ef9f0838fee39b62d653e30
init version: fec3683
Security Options:
seccomp
Profile: default
Kernel Version: 3.10.0-957.el7.x86_64
Operating System: CentOS Linux 7 (Core)
OSType: linux
Architecture: x86_64
CPUs: 4
Total Memory: 3.683GiB
Name: localhost.localdomain
ID: KDKJ:IZFD:G32Q:DHWP:ORN6:EBWW:Q466:OAF7:MN6K:6WVY:T3M2:4VID
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): false
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
127.0.0.0/8
Live Restore Enabled: false
Product License: Community Engine
[root@localhost ~]# docker -v
Docker version 18.09.5, build e8ff056
thanks .. its working
ReplyDeleteThanks so much Ashish. It works on RHEL 7.6
ReplyDeletethanks Ashish, this post was helpful
ReplyDeleteThanks worked pefectly on RHEL 7.6
ReplyDeleteThanks...
ReplyDeleteGreat blog!! Thanks for sharing
ReplyDeleteKubernetes Online Training
Docker Online Training
Docker Training in Hyderabad
Kubernetes Training in Hyderabad
anyone want to learn advance devops tools or devops online training visit
ReplyDeleteDevOps Training in Bangalore | Certification | Online Training Course institute | DevOps Training in Hyderabad | Certification | Online Training Course institute | DevOps Training in Coimbatore | Certification | Online Training Course institute | DevOps Online Training | Certification | Devops Training Online