docker 之cp命令使用
2017-07-19 21:28
519 查看
为了比较详细地描述docker ps 地用法,首先得了解我用来
说明的镜像的dockerfile
如下
以上就是我用来说明的镜像
1. 从 container 到 主机(host)
现在我要从镜像v1.0.14所起的容器中cp /work/conf/nginx.conf 文件
docker run
docker cp
2. 从 主机(host) 到 container
之后 你docker commit 就可以保存该容器为新镜像了
说明的镜像的dockerfile
如下
➜ openresty git:(master) cat Dockerfile FROM harbor.enncloud.cn/qinzhao-harbor/ubuntu-openresty:v1.0.0 ENV PATH /usr/local/openresty/nginx/sbin:$PATH ADD nginx.conf /work/conf/ WORKDIR /work/ EXPOSE 8080 #CMD ["nginx", "-g", "daemon off;"] CMD /usr/local/openresty/nginx/sbin/nginx -g 'daemon off;' -c /work/conf/nginx.conf
➜ openresty git:(master) sudo docker images REPOSITORY TAG IMAGE ID CREATED SIZE r 4000 eg.enncloud.cn/qinzhao-harbor/ubuntu-openresty v1.0.14 6f086fe82845 46 hours ago 482 MB
以上就是我用来说明的镜像
1. 从 container 到 主机(host)
docker cp <containerId>:/file/path/within/container /host/path/target
现在我要从镜像v1.0.14所起的容器中cp /work/conf/nginx.conf 文件
docker run
➜ openresty git:(master) sudo docker run -d -p 9090:8080 reg.enncloud.cn/qinzhao-harbor/ubuntu-openresty:v1.0.14 Password: 4bbb4313ac0d9401255dc116d6aa9f381a5bcd04e96a611b7139cc6dfb612d7f
➜ openresty git:(master) ll total 16 -rw-r--r-- 1 xinzhiyun staff 292B 7 17 23:59 Dockerfile -rw-r--r-- 1 xinzhiyun staff 0B 7 18 00:08 README.md -rw-r--r-- 1 xinzhiyun staff 294B 7 17 22:44 nginx.conf drwxr-xr-x 2 xinzhiyun staff 68B 7 19 21:39 test ➜ openresty git:(master) ls test ➜ openresty git:(master)
docker cp
➜ openresty git:(master) sudo docker cp 4bbb4313ac0d:/work/conf/nginx.conf ./test/ ➜ openresty git:(master) ✗ ll test total 8 -rw-r--r-- 1 root staff 294B 7 17 22:44 nginx.conf
2. 从 主机(host) 到 container
➜ openresty git:(master) ✗ sudo docker exec -it 4bbb4313ac0d sh # ls conf logs # cd # pwd /root # ls #
➜ openresty git:(master) ✗ sudo docker cp test/nginx.conf 4bbb4313ac0d:/root/ Password: ➜ openresty git:(master) ✗
➜ openresty git:(master) ✗ sudo docker exec -it 4bbb4313ac0d sh # pwd /root # ls nginx.conf #
之后 你docker commit 就可以保存该容器为新镜像了
相关文章推荐
- LINUX中CP命令使用
- Linux下CP命令的使用!
- linux下cp命令的使用
- cp命令使用之大误
- 当使用cp命令时出现略过文件夹时处理方法
- Linux中cp和scp命令的使用方法
- Windows 和UNIX 上使用java –cp 命令的一点小小区别 分号和冒号的区别
- 使用共享内存和信号量模仿cp命令
- Linux中cp和scp命令的使用方法
- Linux中cp和scp命令的使用方法
- linux中cp 命令使用介绍(复制文件或者目录)
- centos 使用 CP 命令 不提示 覆盖
- Linux中cp和scp命令的使用
- linux中的一些基础命令的使用(which,whereis,locate,find,alias,file,ls,cat,echo,tar,bzip2,gzip,history,mv,cp,rm)
- Linux 使用 cp 命令强制覆盖功能
- 如何使用 docker 及常用命令(一)
- Linux 使用 cp 命令强制覆盖功能
- Linux使用cp命令直接覆盖不提示的方法
- cp命令的使用
- Linux使用cp命令直接覆盖不提示的方法