CentOS Stream 9
Sponsored Link

Docker : Install2022/07/29

 
Install Docker which is the Operating System-Level Virtualization Tool, which automates the deployment of applications inside Containers.
[1] Install Docker CE.
# remove conflict packages with Docker first

[root@dlp ~]#
dnf -y remove podman runc
[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 ~]#
rpm -q docker-ce

docker-ce-20.10.17-3.el9.x86_64
[root@dlp ~]#
docker version

Client: Docker Engine - Community
 Version:           20.10.17
 API version:       1.41
 Go version:        go1.17.11
 Git commit:        100c701
 Built:             Mon Jun  6 23:03:29 2022
 OS/Arch:           linux/amd64
 Context:           default
 Experimental:      true

Server: Docker Engine - Community
 Engine:
  Version:          20.10.17
  API version:      1.41 (minimum version 1.12)
  Go version:       go1.17.11
  Git commit:       a89b842
  Built:            Mon Jun  6 23:01:12 2022
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.6.6
  GitCommit:        10c12954828e7c7c9b6e0ea9b0c02b01407d3ae1
 runc:
  Version:          1.1.2
  GitCommit:        v1.1.2-0-ga916309
 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 quay.io/centos/centos:stream9
stream9: Pulling from centos/centos
fda517edff60: Pull complete
Digest: sha256:07f9ccafb44a1de11a1c2c2bad3fcc10cd224921f9f1c9c6e778b723c740c24a
Status: Downloaded newer image for quay.io/centos/centos:stream9
quay.io/centos/centos:stream9

# run echo inside Container

[root@dlp ~]#
docker run quay.io/centos/centos:stream9 /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 quay.io/centos/centos:stream9 /bin/bash

[root@7a9a1110135b /]#    
# Container's console

[root@7a9a1110135b /]#
uname -a

Linux 7a9a1110135b 5.14.0-130.el9.x86_64 #1 SMP PREEMPT_DYNAMIC Fri Jul 15 11:24:09 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
[root@7a9a1110135b /]#
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@b8abdf33218c /]# [root@dlp ~]#    
# Ctrl+p, Ctrl+q
# show docker processes

[root@dlp ~]#
docker ps

CONTAINER ID   IMAGE                           COMMAND       CREATED         STATUS         PORTS     NAMES
b8abdf33218c   quay.io/centos/centos:stream9   "/bin/bash"   6 seconds ago   Up 5 seconds             fervent_blackwell

# connect to container's session

[root@dlp ~]#
docker attach b8abdf33218c

[root@b8abdf33218c /]#
# shutdown container's process from Host's console

[root@dlp ~]#
docker kill b8abdf33218c

b8abdf33218c
[root@dlp ~]#
docker ps

CONTAINER ID   IMAGE     COMMAND   CREATED   STATUS    PORTS     NAMES

Matched Content