背景
Docker只提供了容器运行的必备依赖,但是一些编辑等操作的依赖是不支持的,如vi操作容器内部文件、将静态资源拷贝到容器内来等。
docker pull nginx
docker run -d -p 81:80 --name=mynginx -v D:/docker/nginx/www:/usr/share/nginx/www -v D:/docker/nginx/conf.d:/etc/nginx/conf.d -v D:/docker/nginx/logs:/var/log/nginx nginx:latest
docker ps
docker exec -it mynginx /bin/bash
cd /usr/share/nginx/html
vi index.html
数据卷文件系统映射关系
数据卷操作
docker volume --help
重新操作
C:\Users\lxh>docker rm -f mynginx
mynginx
C:\Users\lxh>docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
C:\Users\lxh>docker run -d --name mynginx -p 80:80 -v html:/usr/share/nginx/html nginx:latest
b108696facb8e592663848972832a31cffb04bc273b7c59f4b51208422873a8e
C:\Users\lxh>docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
b108696facb8 nginx:latest "/docker-entrypoint.…" 11 seconds ago Up 9 seconds 0.0.0.0:80->80/tcp mynginx
C:\Users\lxh>docker volume ls
DRIVER VOLUME NAME
local 1b7c4656d25cfcfea00a52377bfbe23a19875185576c7ab1192bcf2e8aacb158
local 6c1a2ee7160cc6b7e46f88b6d3088bb2467171d2e35a40d4c779c51a03576ec4
local 8c4d84dfd14147ac5eed1f1f8623a5abbc5abb63f270607b098960f8935e18b0
local 9da8a52d684e77728dc65d382918c471155efdea525e5d0085c74b9f9ce4aab7
local 73fd28f50390456a4e110b880d49382321f2b9ce12a9c68ee3e46295c2d24155
local 7113d849d6ae46ba9d2cc513e7bb93b6b60342ee0df93b4990f60264cef54eea
local a8d5204474a6d341c69723acd0810c30bb81dc07c5d10bead665533b82411692
local html
C:\Users\lxh>