Docker : Install2021/04/06 |
Install Docker which is the Operating System-Level Virtualization Tool, which automates the deployment of applications inside Containers.
|
|
[1] | Install Docker CE. |
[root@dlp ~]# curl https://download.docker.com/linux/centos/docker-ce.repo -o /etc/yum.repos.d/docker-ce.repo [root@dlp ~]# sed -i -e "s/enabled=1/enabled=0/g" /etc/yum.repos.d/docker-ce.repo
[root@dlp ~]#
dnf --enablerepo=docker-ce-stable -y install docker-ce
[root@dlp ~]#
systemctl enable --now docker
[root@dlp ~]#
[root@dlp ~]# rpm -q docker-ce docker-ce-20.10.5-3.el8.x86_64 docker version Client: Docker Engine - Community Version: 20.10.5 API version: 1.41 Go version: go1.13.15 Git commit: 55c4c88 Built: Tue Mar 2 20:17:04 2021 OS/Arch: linux/amd64 Context: default Experimental: true Server: Docker Engine - Community Engine: Version: 20.10.5 API version: 1.41 (minimum version 1.12) Go version: go1.13.15 Git commit: 363e9a8 Built: Tue Mar 2 20:15:27 2021 OS/Arch: linux/amd64 Experimental: false containerd: Version: 1.4.4 GitCommit: 05f951a3781f4f2c1911b05e61c160e9c30eaa8e runc: Version: 1.0.0-rc93 GitCommit: 12644e614e25b05da6fd08a38ffa0cfe1903fdec docker-init: Version: 0.19.0 GitCommit: de40ad0 |
[2] | Download an official image and create a Container and output the words [Welcome to the Docker World] inside the Container. |
# download the image [root@dlp ~]# docker pull centos
Using default tag: latest latest: Pulling from library/centos 7a0437f04f83: Pull complete Digest: sha256:5528e8b1b1719d34604c87e11dcd1c0a20bedf46e83b5632cdeac91b8c04efc1 Status: Downloaded newer image for centos:latest docker.io/library/centos:latest # run echo inside Container [root@dlp ~]# docker run centos /bin/echo "Welcome to the Docker World!" Welcome to the Docker World! |
[3] | Connect to the interactive session of a Container with [i] and [t] option like follows. If exit from the Container session, the process of a Container finishes. |
[root@dlp ~]# docker run -it centos /bin/bash [root@60bab47a4c89 /]# # Container's console [root@60bab47a4c89 /]# uname -a Linux 60bab47a4c89 4.18.0-294.el8.x86_64 #1 SMP Mon Mar 15 22:38:42 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux [root@60bab47a4c89 /]# exit exit [root@dlp ~]# # come back
|
[4] | If exit from the Container session with keeping container's process, push [Ctrl+p] and [Ctrl+q] key. |
[root@dlp ~]#
docker run -it centos /bin/bash [root@8480e1a203ba /]# [root@dlp ~]# # Ctrl+p, Ctrl+q
# show docker processes [root@dlp ~]# docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 8480e1a203ba centos "/bin/bash" 12 seconds ago Up 11 seconds gifted_kalam # connect to container's session [root@dlp ~]# docker attach 8480e1a203ba [root@8480e1a203ba /]# # shutdown container's process from Host's console [root@dlp ~]# docker kill 8480e1a203ba 8480e1a203ba [root@dlp ~]# docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES |
Sponsored Link |