1. 添加国内docker image下载加速源
方法是:修改 /etc/docker/daemon.json
,加上如下的键值:
{ "registry-mirrors": ["https://registry.docker-cn.com"] }
之后重启docker服务即可生效。
之后可以直接使用docker pull
命令将仓库中的镜像拉到本地
docker search tutorial
docker pull tutorial
2. 镜像操作:
a) 通过docker images
命令可以看到本地已有的镜像:
docker images #查看镜像
docker run -itd --name=container1 -net=none 镜像:镜像tag bash #以容器名container后台运行镜像 docker exec -it 容器名 /bin/bash #进入镜像bash
docker exec -it --user=myu 9d38a720127c /bin/bash #指定用户myu登录镜像 dcker rmi 镜像id #删除镜像
b)修改后提交新镜像
$ docker commit 69079aaaaab1 ubuntu:update 13132d42da3cc40e8d8b4601a7e2f4dbf198e9d72e37e19ee1986c280ffcb97c $ docker images REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE ubuntu update 13132d42da3c 5 days ago 213 MB ...
$ docker diff 69079aaaaab1 #查看修改
c) 导出container
$ docker ps -a CONTAINER ID IMAGE COMMAND CREATED ... NAMES 77d9619a7a71 ubuntu:14.04 "/bin/bash" 10 seconds ago ... high_shockley $ docker export 77d9619a7a71 > update.tar $ ls update.tar
d)导入container
$ docker import - update < update.tar #等价于docker import update.tar update 157bcbb5fdfce0e7c10ef67ebdba737a491214708a5f266a3c74aa6b0cfde078 $ docker images REPOSITORY TAG IMAGE ID ... VIRTUAL SIZE update latest 157bcbb5fdfc ... 188.1 MB
e) save and load image
$ docker save -o update1.tar update
$ ls -l
total 385168
-rw-rw-r-- 1 vagrant vagrant 197206528 Jan 13 14:13 update1.tar
-rw-rw-r-- 1 vagrant vagrant 197200896 Jan 13 14:05 update.tar
$ docker rmi update
Untagged: update:latest
Deleted: 157bcbb5fdfce0e7c10ef67ebdba737a491214708a5f266a3c74aa6b0cfde078
$ docker load < update1.tar #或docker load -i update1.tar
$ docker images
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
update latest 157bcbb5fdfc 5 minutes ago 188.1 MB
ubuntu 14.04 8eaa4ff06b53 12 days ago 192.7 MB
https://blog.csdn.net/moshenglv/article/details/82623410
参考链接:https://blog.csdn.net/qq_33256688/article/details/80319673
dockerfile概念:https://blog.csdn.net/styshoo/article/details/56663522