●サービス開始
[root@rh74 ~]# systemctl start docker.service
●サービス状態確認
[root@rh74 ~]# systemctl status docker.service
● docker.service - Docker Application Container Engine
Loaded: loaded (/usr/lib/systemd/system/docker.service; disabled; vendor preset: disabled)
Active: active (running) since 月 2019-10-21 00:16:32 JST; 19s ago
Docs: http://docs.docker.com
Main PID: 4490 (dockerd-current)
CGroup: /system.slice/docker.service
tq4490 /usr/bin/dockerd-current --add-runtime docker-runc=/usr/libexec...
mq4497 /usr/bin/docker-containerd-current -l unix:///var/run/docker/li...
10月 21 00:16:30 rh74 dockerd-current[4490]: time="2019-10-21T00:16:30.98546113..."
10月 21 00:16:32 rh74 dockerd-current[4490]: time="2019-10-21T00:16:32.36825775..."
10月 21 00:16:32 rh74 dockerd-current[4490]: time="2019-10-21T00:16:32.36933005..."
10月 21 00:16:32 rh74 dockerd-current[4490]: time="2019-10-21T00:16:32.40720094..."
10月 21 00:16:32 rh74 dockerd-current[4490]: time="2019-10-21T00:16:32.66237838..."
10月 21 00:16:32 rh74 dockerd-current[4490]: time="2019-10-21T00:16:32.87764151..."
10月 21 00:16:32 rh74 dockerd-current[4490]: time="2019-10-21T00:16:32.95384278..."
10月 21 00:16:32 rh74 dockerd-current[4490]: time="2019-10-21T00:16:32.95407665...1
10月 21 00:16:32 rh74 systemd[1]: Started Docker Application Container Engine.
10月 21 00:16:32 rh74 dockerd-current[4490]: time="2019-10-21T00:16:32.97417491..."
Hint: Some lines were ellipsized, use -l to show in full.
[root@rh74 ~]# docker info
Containers: 0
Running: 0
Paused: 0
Stopped: 0
Images: 0
Server Version: 1.13.1
Storage Driver: overlay2
Backing Filesystem: xfs
Supports d_type: true
Native Overlay Diff: true
Logging Driver: journald
Cgroup Driver: systemd
Plugins:
Volume: local
Network: bridge host macvlan null overlay
Authorization: rhel-push-plugin
Swarm: inactive
Runtimes: docker-runc runc
Default Runtime: docker-runc
Init Binary: /usr/libexec/docker/docker-init-current
containerd version: (expected: aa8187dbd3b7ad67d8e5e3a15115d3eef43a7ed1)
runc version: 9c3c5f853ebf0ffac0d087e94daef462133b69c7 (expected: 9df8b306d01f59d3a8029be411de015b7304dd8f)
init version: fec3683b971d9c3ef73f284f176672c44b448662 (expected: 949e6facb77383876aeff8a6944dde66b3089574)
Security Options:
seccomp
WARNING: You're not using the default seccomp profile
Profile: /etc/docker/seccomp.json
selinux
Kernel Version: 3.10.0-693.el7.x86_64
Operating System: Red Hat Enterprise Linux
OSType: linux
Architecture: x86_64
Number of Docker Hooks: 3
CPUs: 1
Total Memory: 992.4 MiB
Name: rh74
ID: IM7R:MBY4:LTZ4:HHHR:S4SZ:RAYO:YJZS:TSLG:FMK4:ER5C:55QX:7O7L
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): false
Registry: https://registry.access.redhat.com/v1/
Experimental: false
Insecure Registries:
127.0.0.0/8
Live Restore Enabled: false
Registries: registry.access.redhat.com (secure), docker.io (secure), registry.fedoraproject.org (secure), quay.io (secure), registry.centos.org (secure), docker.io (secure)
●Docker公式レジストリからイメージを検索する
[root@rh74 ~]# docker search centos
INDEX NAME DESCRIPTION STARS OFFICIAL AUTOMATED
docker.io docker.io/centos The official build of CentOS. 5616 [OK]
docker.io docker.io/centos The official build of CentOS. 5616 [OK]
docker.io docker.io/ansible/centos7-ansible Ansible on Centos7 124 [OK]
docker.io docker.io/ansible/centos7-ansible Ansible on Centos7 124 [OK]
docker.io docker.io/jdeathe/centos-ssh OpenSSH / Supervisor / EPEL/IUS/SCL Repos ... 114 [OK]
docker.io docker.io/jdeathe/centos-ssh OpenSSH / Supervisor / EPEL/IUS/SCL Repos ... 114 [OK]
docker.io docker.io/consol/centos-xfce-vnc Centos container with "headless" VNC sessi... 99 [OK]
[root@rh74 ~]# docker search vsftpd
INDEX NAME DESCRIPTION STARS OFFICIAL AUTOMATED
docker.io docker.io/fauria/vsftpd vsftpd Docker image based on Centos 7. Sup... 76 [OK]
docker.io docker.io/fauria/vsftpd vsftpd Docker image based on Centos 7. Sup... 76 [OK]
docker.io docker.io/panubo/vsftpd vsftpd - Secure, fast FTP server 23 [OK]
docker.io docker.io/panubo/vsftpd vsftpd - Secure, fast FTP server 23 [OK]
●ダウンロード
[root@rh74 ~]# docker pull centos
Using default tag: latest
Trying to pull repository registry.access.redhat.com/centos ...
Pulling repository registry.access.redhat.com/centos
Trying to pull repository docker.io/library/centos ...
latest: Pulling from docker.io/library/centos
729ec3a6ada3: Pull complete
Digest: sha256:f94c1d992c193b3dc09e297ffd54d8a4f1dc946c37cbeceb26d35ce1647f88d9
Status: Downloaded newer image for docker.io/centos:latest
[root@rh74 ~]# docker pull docker.io/fauria/vsftpd
Using default tag: latest
Trying to pull repository docker.io/fauria/vsftpd ...
latest: Pulling from docker.io/fauria/vsftpd
d8d02d457314: Pull complete
1b736e561fc2: Pull complete
3fc2d5ca0818: Pull complete
d1a79586d7a2: Pull complete
df260f25215a: Pull complete
0c8b59e58472: Pull complete
2e51b576696b: Pull complete
45830c2b6b6e: Pull complete
0d1d2099cdc9: Pull complete
b45e9cd1507e: Pull complete
Digest: sha256:5cd0cd3d674f6ec7668f24e4c0e6d56ce07afe050ea007b1b55077a29e16aca8
Status: Downloaded newer image for docker.io/fauria/vsftpd:latest
[root@rh74 ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
docker.io/fauria/vsftpd latest 2497f179cf1d 5 days ago 391 MB
docker.io/centos latest 0f3e07c0138f 2 weeks ago 220 MB
●dockerコンテナ作成
[root@rh74 ~]# docker run -it centos:latest /bin/bash
※イメージ「centos:latest」を「-it(コンテナとホストの入出力をつなげる)」オプションで起動し、「/bin/bash」を実行するという意味かな?
※最後の/bin/bashは無くても同じ動きだった。
[root@94c21fb5273b /]# cat /etc/centos-release
CentOS Linux release 8.0.1905 (Core)
※CentOSのバージョンが見れる
[root@94c21fb5273b /]# uname -n
94c21fb5273b
[root@94c21fb5273b /]# uname -a
Linux 94c21fb5273b 3.10.0-693.el7.x86_64 #1 SMP Thu Jul 6 19:56:57 EDT 2017 x86_64 x86_64 x86_64 GNU/Linux
※カーネルはホストと同じバージョンが表示される
[root@94c21fb5273b /]# df -h
Filesystem Size Used Avail Use% Mounted on
overlay 2.0G 1.2G 811M 61% /
tmpfs 497M 0 497M 0% /dev
tmpfs 497M 0 497M 0% /sys/fs/cgroup
/dev/sda5 2.0G 1.2G 811M 61% /etc/hosts
shm 64M 0 64M 0% /dev/shm
tmpfs 497M 0 497M 0% /proc/acpi
tmpfs 497M 0 497M 0% /proc/scsi
tmpfs 497M 0 497M 0% /sys/firmware
[root@94c21fb5273b /]# ps -elf
F S UID PID PPID C PRI NI ADDR SZ WCHAN STIME TTY TIME CMD
4 S root 1 0 0 80 0 - 3004 do_wai 15:46 ? 00:00:00 /bin/bash
0 R root 18 1 0 80 0 - 10984 - 15:57 ? 00:00:00 ps -elf
●dockerの外から見ると
[root@rh74 ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
94c21fb5273b centos:latest "/bin/bash" 11 minutes ago Up 11 minutes festive_clarke
[root@rh74 ~]# df -h
ファイルシス サイズ 使用 残り 使用% マウント位置
/dev/sda2 5.0G 87M 5.0G 2% /
devtmpfs 483M 0 483M 0% /dev
tmpfs 497M 0 497M 0% /dev/shm
tmpfs 497M 7.2M 490M 2% /run
tmpfs 497M 0 497M 0% /sys/fs/cgroup
/dev/sda3 5.0G 3.4G 1.7G 67% /usr
/dev/sda5 2.0G 1.2G 811M 61% /var
/dev/mapper/vg01-lv01 1017M 141M 877M 14% /bk
/dev/sda6 2.0G 33M 2.0G 2% /tmp
/dev/sda1 1014M 158M 857M 16% /boot
/dev/sda7 2.0G 33M 2.0G 2% /home
tmpfs 100M 8.0K 100M 1% /run/user/0
/dev/sr0 3.8G 3.8G 0 100% /media
tmpfs 100M 12K 100M 1% /run/user/42
overlay 2.0G 1.2G 811M 61% /var/lib/docker/overlay2/b53ebe54a580a515434481e174c2bc54826c96dec322f7672c4b246e220f73e6/merged
shm 64M 0 64M 0% /var/lib/docker/containers/94c21fb5273bda1f248090568990ba153dce952a8ee3a51a7c0e7e6751cf1762/shm
[root@rh74 ~]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
94c21fb5273b centos:latest "/bin/bash" 14 minutes ago Up 14 minutes festive_clarke
5ff06a527897 centos:latest "/bin/bash" 14 minutes ago Exited (0) 14 minutes ago thirsty_hodgkin
※起動していないコンテナも表示される
[root@rh74 ~]# docker rm 5ff06a527897
5ff06a527897
※コンテナの削除
[root@rh74 ~]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
94c21fb5273b centos:latest "/bin/bash" 20 minutes ago Up 20 minutes festive_clarke