1.查看镜像,如果没有 那么使用docker pull拉取镜像
J:\docker>docker images REPOSITORY TAG IMAGE ID CREATED SIZE centos 7 8652b9f0cb4c 3 weeks ago 204MB docker/getting-started latest 67a3629d4d71 5 weeks ago 27.2MB redis 5.0.9 987b553c835f 5 weeks ago 98.3MB docker/desktop-kubernetes kubernetes-v1.19.3-cni-v0.8.5-critools-v1.17.0 7f85afe431d8 7 weeks ago 285MB wurstmeister/kafka latest 40094a582680 3 months ago 435MB centos latest 0d120b6ccaa8 3 months ago 215MB hyperf/hyperf latest a8fdc61b1fc5 4 months ago 80.2MB redislabs/rebloom latest 03841e395ca0 4 months ago 104MB harisekhon/hbase 1.3 cadb170e663b 9 months ago 236MB wurstmeister/zookeeper latest 3f43f72cb283 22 months ago 510MB
2.
创建两个容器并使用进行连接 J:\docker>docker run -it --name centos1 8652b9f0cb4c /bin/sh sh-4.2# su [root@104de7aeeee2 /]# J:\docker>docker run -it --name centos2 8652b9f0cb4c /bin/sh sh-4.2# su [root@8b65cabe3c8c /]# 查看容器 J:\docker>docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 8b65cabe3c8c 8652b9f0cb4c "/bin/sh" 28 seconds ago Up 27 seconds centos2 104de7aeeee2 8652b9f0cb4c "/bin/sh" About a minute ago Up About a minute centos1