> For the complete documentation index, see [llms.txt](https://monksoul.gitbook.io/hoa/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://monksoul.gitbook.io/hoa/dockerrongqihua/dockerfileuploadshare.md).

# 25.14、Dockerfile 打包、上传、分享

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

## 打包命令

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

`-t`：target，指定当前镜像版本

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

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

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

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

## 登录 docker hub平台

```bash
docker login
```

```bash
[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]#
```

## 上传

```bash
docker push monksoul/nginx-test:v1.0.0
```

```bash
[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]#
```

![](https://3801536837-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M7kU_Hr8e2bVvygGB-6%2F-M9beoLUzTHecQXuZqAg%2F-M9bf9gzsQt28CBuB1QO%2FSnipaste_2019-05-09_15-42-21.png?alt=media\&token=1548e1a1-5ab4-4381-8d3e-ff234c77c76a)
