安装docker:
yum -y install docker
下载镜像:
docker search centos //搜索镜像
[root@192 docker]
Trying to pull repository docker.io/library/centos ...
7.2.1511: Pulling from docker.io/library/centos
a8c7037c15e9: Pull complete
Digest: sha256:50cca1e74da4b6a4eb4ade029c8fdd4ee8564776801914d9bd89df8c6344add0
Status: Downloaded newer image for docker.io/centos:7.2.1511
[root@192 docker]
REPOSITORY TAG IMAGE ID CREATED SIZE
docker.io/centos 7.2.1511 9aec5c5fe4ba 3 years ago 195 MB
[root@192 docker]
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
启动容器: ??因为是在1台虚拟机搭建3个docker的缘故,所以这次选择的docker 网卡类型为bridge模式(bridge模式容器ip无法自己指定),网段为 172.17.0.0/16 网关为172.17.0.1,三台容器的主机名和ip分别为:
server 172.17.0.2
agent1 172.17.0.3
agent2 172.17.0.4
[root@192 docker]
e35571a1261d70173ceb6ed33c84d04bf8b300c0fb073b23ac67afa335980b4f
[root@192 docker]
87fa9ab888066f45023999f77152df140a8b6d8b5b4dd47ce166bd7f99025a36
[root@192 docker]
8b685b1e4177f62bc74f4c535e1905298c09ed97ab520f43b9b6b82c01e51a21
[root@192 docker]
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
8b685b1e4177 docker.io/centos:7.2.1511 "/bin/bash" About a minute ago Up About a minute agent2
87fa9ab88806 docker.io/centos:7.2.1511 "/bin/bash" 2 minutes ago Up 2 minutes agent1
e35571a1261d docker.io/centos:7.2.1511 "/bin/bash" 2 minutes ago Up 2 minutes server
[root@192 docker]
[root@server /]
[root@192 ~]
Error response from daemon: Container e35571a1261d70173ceb6ed33c84d04bf8b300c0fb073b23ac67afa335980b4f is not running
[root@192 ~]
server
重启docker服务:
[root@192 docker]
[root@192 docker]
● docker.service - Docker Application Container Engine
Loaded: loaded (/usr/lib/systemd/system/docker.service; disabled; vendor preset: disabled)
Active: active (running) since Mon 2022-03-21 00:25:56 PDT; 28min ago
Docs: http://docs.docker.com
Main PID: 50766 (dockerd-current)
Memory: 18.0M
CGroup: /system.slice/docker.service
├─50766 /usr/bin/dockerd-current --add-runtime docker-runc=/usr/libexec/docker/docker-runc-current --default-runtime=docker...
├─50776 /usr/bin/docker-containerd-current -l unix:///var/run/docker/libcontainerd/docker-containerd.sock --metrics-interva...
├─51467 /usr/bin/docker-containerd-shim-current e35571a1261d70173ceb6ed33c84d04bf8b300c0fb073b23ac67afa335980b4f /var/run/d...
├─51573 /usr/bin/docker-containerd-shim-current 87fa9ab888066f45023999f77152df140a8b6d8b5b4dd47ce166bd7f99025a36 /var/run/d...
└─51665 /usr/bin/docker-containerd-shim-current 8b685b1e4177f62bc74f4c535e1905298c09ed97ab520f43b9b6b82c01e51a21 /var/run/d...
Mar 21 00:25:56 192.168.42.132 dockerd-current[50766]: time="2022-03-21T00:25:56.328358495-07:00" level=info msg="Firewalld runn...false"
Mar 21 00:25:56 192.168.42.132 dockerd-current[50766]: time="2022-03-21T00:25:56.436304532-07:00" level=info msg="Default bridge...dress"
Mar 21 00:25:56 192.168.42.132 dockerd-current[50766]: time="2022-03-21T00:25:56.588477237-07:00" level=info msg="Loading contai...done."
Mar 21 00:25:56 192.168.42.132 dockerd-current[50766]: time="2022-03-21T00:25:56.730061633-07:00" level=info msg="Daemon has com...ation"
Mar 21 00:25:56 192.168.42.132 dockerd-current[50766]: time="2022-03-21T00:25:56.730927542-07:00" level=info msg="Docker daemon"...1.13.1
Mar 21 00:25:56 192.168.42.132 systemd[1]: Started Docker Application Container Engine.
Mar 21 00:25:56 192.168.42.132 dockerd-current[50766]: time="2022-03-21T00:25:56.757134704-07:00" level=info msg="API listen on ....sock"
Mar 21 00:42:08 192.168.42.132 oci-umount[51500]: umounthook <debug>: prestart container_id:e35571a1261d rootfs:/var/lib/docker/...rootfs
Mar 21 00:42:21 192.168.42.132 dockerd-current[50766]: time="2022-03-21T00:42:21.421376820-07:00" level=error msg="Handler for POST /v...
Mar 21 00:42:50 192.168.42.132 oci-umount[51606]: umounthook <debug>: prestart container_id:87fa9ab88806 rootfs:/var/lib/docker/...rootfs
Hint: Some lines were ellipsized, use -l to show in full.
重启过程中遇到的问题:
[root@192 docker]
Job for docker.service failed because the control process exited with error code. See "systemctl status docker.service" and "journalctl -xe" for details.
vim /etc/sysconfig/docker-storage
DOCKER_STORAGE_OPTIONS="--selinux-enabled --log-driver=journald --signature-verification=false"
vim /etc/docker/daemon.json
{ "storage-driver": "devicemapper" }
将本地文件上传到docker容器中:
[root@192 ~]
e35571a1261d70173ceb6ed33c84d04bf8b300c0fb073b23ac67afa335980b4f
[root@192 ~]
删除容器:
[root@192 ~]
f46b3d7c8b51
|