CentOS 7
Sponsored Link

Docker : Install2015/01/10

 
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 ~]#
yum --enablerepo=docker-ce-stable -y install docker-ce
[root@dlp ~]#
systemctl enable --now docker
[root@dlp ~]#
rpm -q docker-ce

docker-ce-20.10.6-3.el7.x86_64
[root@dlp ~]#
docker version

Client: Docker Engine - Community
 Version:           20.10.6
 API version:       1.41
 Go version:        go1.13.15
 Git commit:        370c289
 Built:             Fri Apr  9 22:45:33 2021
 OS/Arch:           linux/amd64
 Context:           default
 Experimental:      true

Server: Docker Engine - Community
 Engine:
  Version:          20.10.6
  API version:      1.41 (minimum version 1.12)
  Go version:       go1.13.15
  Git commit:       8728dd2
  Built:            Fri Apr  9 22:43:57 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@0e6c5c3cd68a /]#    
# Container's console

[root@0e6c5c3cd68a /]#
uname -a

Linux 0e6c5c3cd68a 3.10.0-1160.6.1.el7.x86_64 #1 SMP Tue Nov 17 13:59:11 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
[root@0e6c5c3cd68a /]#
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@41ba6a71aea9 /]# [root@dlp ~]#    
# Ctrl+p, Ctrl+q
# show docker processes

[root@dlp ~]#
docker ps

CONTAINER ID   IMAGE     COMMAND       CREATED         STATUS         PORTS     NAMES
41ba6a71aea9   centos    "/bin/bash"   9 seconds ago   Up 8 seconds             serene_johnson

# connect to container's session

[root@dlp ~]#
docker attach 41ba6a71aea9

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

[root@dlp ~]#
docker kill 41ba6a71aea9

8480e1a203ba
[root@dlp ~]#
docker ps

CONTAINER ID   IMAGE     COMMAND   CREATED   STATUS    PORTS     NAMES

Matched Content