Debian 12 bookworm
Sponsored Link

Docker : Install2023/06/22

 
Install Docker which is the Operating System-Level Virtualization Tool, which automates the deployment of applications inside Containers.
[1] Install Docker.
root@dlp:~#
apt -y install docker.io
root@dlp:~#
docker version

Client:
 Version:           20.10.24+dfsg1
 API version:       1.41
 Go version:        go1.19.8
 Git commit:        297e128
 Built:             Thu May 18 08:38:34 2023
 OS/Arch:           linux/amd64
 Context:           default
 Experimental:      true

Server:
 Engine:
  Version:          20.10.24+dfsg1
  API version:      1.41 (minimum version 1.12)
  Go version:       go1.19.8
  Git commit:       5d6db84
  Built:            Thu May 18 08:38:34 2023
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.6.20~ds1
  GitCommit:        1.6.20~ds1-1+b1
 runc:
  Version:          1.1.5+ds1
  GitCommit:        1.1.5+ds1-1+b1
 docker-init:
  Version:          0.19.0
  GitCommit:
[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 debian
Using default tag: latest
latest: Pulling from library/debian
bba7bb10d5ba: Pull complete
Digest: sha256:d568e251e460295a8743e9d5ef7de673c5a8f9027db11f4e666e96fb5bed708e
Status: Downloaded newer image for debian:latest
docker.io/library/debian:latest

# run echo inside Container

root@dlp:~#
docker run debian /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 debian /bin/bash

root@6ad840b78fba:/#    
# Container's console

root@6ad840b78fba:/#
uname -a

Linux 6ad840b78fba 6.1.0-9-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.27-1 (2023-05-08) x86_64 GNU/Linux
root@6ad840b78fba:/#
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 debian /bin/bash

root@072c016558ac:/# root@dlp:~#    
# Ctrl+p, Ctrl+q
# show docker process

root@dlp:~#
docker ps

CONTAINER ID   IMAGE     COMMAND       CREATED          STATUS          PORTS     NAMES
072c016558ac   debian    "/bin/bash"   25 seconds ago   Up 24 seconds             gracious_kirch

# connect to container's session

root@dlp:~#
docker attach 072c016558ac

root@072c016558ac:/#
# shutdown container's process from Host's console

root@dlp:~#
docker kill 072c016558ac

072c016558ac
root@dlp:~#
docker ps

CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES

Matched Content