25.14、Dockerfile 打包、上传、分享

如何打包我们的镜像、上传我们的镜像和分享我们的镜像。

打包命令

docker build -t nginx-test:v1.0.0 .

-t:target,指定当前镜像版本

最后面的 ==.== 不能省略,表示当前路径,会自动找当前目录下的Dockerfile文件

提交到Docker 仓库 https://hub.docker.com/

添加上线版本信息,区别于内部开发版本,==注意用户名:monksoul==

docker tag nginx-test:v1.0.0 monksoul/nginx-test:v1.0.0

登录 docker hub平台

docker login
[root@localhost aspnetcore]# docker login
Login with your Docker ID to push and pull images from Docker Hub. If you don't have a Docker ID, head over to https://hub.docker.com to create one.
Username: monksoul
Password: 
WARNING! Your password will be stored unencrypted in /root/.docker/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-store

Login Succeeded
[root@localhost aspnetcore]#

上传

docker push monksoul/nginx-test:v1.0.0
[root@localhost aspnetcore]# docker push monksoul/nginx-test:v1.0.0
The push refers to repository [docker.io/monksoul/nginx-test]
e021b86e389d: Pushed 
332fa54c5886: Mounted from library/nginx 
6ba094226eea: Mounted from library/nginx 
6270adb5794c: Mounted from library/mysql 
v1.0.0: digest: sha256:b941ed05f056909ac9af01ed04492ccde07e0b41f5d77a57201446c147614b36 size: 1155
[root@localhost aspnetcore]#

最后更新于