Docker : Install2020/12/14 |
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.0-3.el8.x86_64 docker version Client: Docker Engine - Community Version: 20.10.0 API version: 1.41 Go version: go1.13.15 Git commit: 7287ab3 Built: Tue Dec 8 18:59:27 2020 OS/Arch: linux/amd64 Context: default Experimental: true Server: Docker Engine - Community Engine: Version: 20.10.0 API version: 1.41 (minimum version 1.12) Go version: go1.13.15 Git commit: eeddea2 Built: Tue Dec 8 18:57:25 2020 OS/Arch: linux/amd64 Experimental: false containerd: Version: 1.4.3 GitCommit: 269548fa27e0089a8b8278fc4fc781d7f65a939b runc: Version: 1.0.0-rc92 GitCommit: ff819c7e9184c13b7c2607fe6c30ae19403a7aff 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@56bd03ffd00d /]# # Container's console [root@56bd03ffd00d /]# uname -a Linux 56bd03ffd00d 4.18.0-193.28.1.el8_2.x86_64 #1 SMP Thu Oct 22 00:20:22 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux [root@56bd03ffd00d /]# 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@0807a3b9f777 /]# [root@dlp ~]# # Ctrl+p, Ctrl+q
# show docker processes [root@dlp ~]# docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 0807a3b9f777 centos "/bin/bash" 15 seconds ago Up 14 seconds nifty_colden # connect to container's session [root@dlp ~]# docker attach 0807a3b9f777 [root@0807a3b9f777 /]# # shutdown container's process from Host's console [root@dlp ~]# docker kill 0807a3b9f777 0807a3b9f777 [root@dlp ~]# docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES |
Sponsored Link |