chenghaodeMacBook-Pro:~ chenghao$ docker tag ubuntu ubuntu_test chenghaodeMacBook-Pro:~ chenghao$ docker images REPOSITORY TAG IMAGE ID CREATED SIZE ubuntu latest 2ca708c1c9cc 3 weeks ago 64.2MB ubuntu_test latest 2ca708c1c9cc 3 weeks ago 64.2MB
如果想修改TAG,则使用docker tag 镜像 xxx:xxx 的形式即可
1 2 3 4 5 6
chenghaodeMacBook-Pro:~ chenghao$ docker tag ubuntu ubuntu_test:test chenghaodeMacBook-Pro:~ chenghao$ docker images REPOSITORY TAG IMAGE ID CREATED SIZE ubuntu latest 2ca708c1c9cc 3 weeks ago 64.2MB ubuntu_test latest 2ca708c1c9cc 3 weeks ago 64.2MB ubuntu_test test 2ca708c1c9cc 3 weeks ago 64.2MB
3 打包新的镜像 docker commit -m “描述” -a “操作人员” CONTAINER ID 新的镜像名
docker tag centos_with_net_tools 192.168.31.232:5000/centos chenghaodeMacBook-Pro:~ chenghao$ docker images REPOSITORY TAG IMAGE ID CREATED SIZE 192.168.31.232:5000/centos latest 9b8543bb78c7 3 hours ago 276MB
推送镜像到私有仓库 (另一个服务器)
1 2 3
docker push 192.168.31.232:5000/centos The push refers to repository [192.168.31.232:5000/centos] Get https://192.168.31.232:5000/v2/: http: server gave HTTP response to HTTPS client
warn:发现推送镜像失败,需要添加仓库路径后重新推送,需要https的方法才能上传,我们可以修改下daemon.json来解决, vim /etc/docker/daemon.json (docker重启后,注意重新启动registry容器)
docker run -itd -p 8080:80 483bcf6d8150 bash 871971b3df433772b452e20059f919f0a8c5a2c5d22ac3981fd33e71016405b0 chenghaodeMacBook-Pro:Documents chenghao$ docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 871971b3df43 483bcf6d8150 "/bin/sh -c '/usr/lo…" 4 seconds ago Up 3 seconds 0.0.0.0:8080->80/tcp serene_bartik chenghaodeMacBook-Pro:Documents chenghao$ curl 127.0.0.1:8080 <!DOCTYPE html> <html> <head> <title>Welcome to nginx!</title> <style> body { width: 35em; margin: 0 auto; font-family: Tahoma, Verdana, Arial, sans-serif; } </style> </head> <body> <h1>Welcome to nginx!</h1> <p>If you see this page, the nginx web server is successfully installed and working. Further configuration is required.</p> <p>For online documentation and support please refer to <a href="http://nginx.org/">nginx.org</a>.<br/> Commercial support is available at <a href="http://nginx.com/">nginx.com</a>.</p> <p><em>Thank you for using nginx.</em></p> </body> </html>