
1、从Docker Hub中下载CentOS Stream 7的Docker镜像注意使用一下命令时需要配置国内Docker镜像网站由于国内无法访问https://index.docker.io造成pull镜像无法连接解决办法在/etc/Docker/下的daemon.json文件中添加一下配置命令{registry-mirrors: [https://docker.1ms.run,https://dockerproxy.net]}保存后进行Docker服务的重启即可正常下载CentOS Stream 7的Docker镜像[rootdocker ~]# sudo systemctl daemon-reload[rootdocker ~]# sudo systemctl restart docker验证是否配置是否生效使用docker pull centos:7下载镜像2、运行一个交互式的CentOS的Docker容器[rootdocker ~]# docker run -it centos:7 /bin/bash3、在新建的容器中创建一个新文件test.txt并查看该文件中的内容[root40c682218824 /]# echo Hello,this is a test file test.txt[root40c682218824 /]# cat test.txtHello,this is a test file退出容器不将其停止[root40c682218824 /]# exitexit4、查看正在运行的容器5、使用后台模式运行一个名为tets1的容器并将主机的80端口映射到test1容器的8080端口上[rootdocker ~]# docker run -itd --name test1 -p 80:8080 centos:76、验证test1容器是否在运行端口映射是否正确[rootdocker ~]# docker ps7、停止test1容器[rootdocker ~]# docker stop test1验证test1容器中是否还在运行8、启动test1容器[rootdocker ~]# docker start test19、重启test1容器[rootdocker ~]# docker restart test110、删除test1容器[rootdocker ~]# docker rm test1