命令总结示意图
![docker-command](https://img2020.cnblogs.com/blog/1321379/202107/1321379-20210728092618949-1403161635.jpg)
docker运行流程示意图
![docker-structure](https://img2020.cnblogs.com/blog/1321379/202107/1321379-20210728094303118-1402716041.png)
镜像命令
docker images 查看本地镜像
docker images centos
REPOSITORY TAG IMAGE ID CREATED SIZE
centos latest 300e315adb2f 7 months ago 209MB
docker search 搜索远端镜像仓
docker search centos
NAME DESCRIPTION STARS OFFICIAL AUTOMATED
centos The official build of CentOS. 6661 [OK]
ansible/centos7-ansible Ansible on Centos7 134 [OK]
docker pull 从远端镜像仓库拉取镜像
> https://hub.docker.com/ # 搜索地址
docker pull centos:centos8.3.2011
centos8.3.2011: Pulling from library/centos
Digest: sha256:5528e8b1b1719d34604c87e11dcd1c0a20bedf46e83b5632cdeac91b8c04efc1
Status: Downloaded newer image for centos:centos8.3.2011
docker.io/library/centos:centos8.3.2011
docker rmi $(docker images -qa) 清空本地镜像仓库
容器命令
docker run -d --name nginx nginx 后台启动容器
docker run -d -p 81:80 nginx 端口映射 81为对外端口 80容器内部端口
docker run --name some-nginx -v /some/content:/usr/share/nginx/html:ro -d nginx
数据映射 /some/content为宿主机文件夹 /usr/share/nginx/html 容器文件夹 ro 代表容器上锁不能修改文件
报错信息:touch: cannot touch '1.txt': Read-only file system
docker exec -it xxxxxx /bin/bash 打开新窗口方式,进入容器
docker rm -f $(docker ps -aq) 强制删除所有容器(实验模式)