一、Dockerhub镜像发布
1.首先在服务器上登录到Docker hub
[root@yang docker]# docker login -u xxx # xxx为dockerhub的账号 Password: # 输入dockerhub账号的密码 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 Succeede
以上显示Login Succeede,说明登录成功!
2.修改新增镜像的命名及标签
语法格式:
docker tag 源镜像ID DockerHub账号/修改后的镜像命名:tagname
现有镜像:
[root@yang docker]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE nginx latest f6d0b4767a6c 2 weeks ago 133MB
新增镜像:
[root@yang docker]# docker tag f6d0b4767a6c xiguajun/nginx3:2.0
[root@yang docker]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
nginx latest f6d0b4767a6c 2 weeks ago 133MB
xiguajun/nginx3 2.0 f6d0b4767a6c 2 weeks ago 133M
解释:
f6d0b4767a6c # 要修改的镜像ID
xiguajun/nginx3 # 新增的镜像命名
2.0 # 自定义tag标签
3.上传(push)镜像到Docker Hub
[root@yang docker]# docker push xiguajun/nginx3:2.0
The push refers to repository [docker.io/xiguajun/nginx3]
85fcec7ef3ef: Pushed
3e5288f7a70f: Pushed
56bc37de0858: Pushed
1c91bf69a08b: Pushed
cb42413394c4: Pushed
2.0: digest: sha256:0b159cd1ee1203dad901967ac55eee18c24da84ba3be384690304be93538bea8 size: 1362
以上则显示push成功!
4.DockerHub上查看
二、阿里云镜像发布
1.登录阿里云,找到容器镜像服务,创建命名空间
2.创建镜像仓库
3.查看创建后的镜像仓库
4.在服务器上登录到阿里云
[root@yang ~]# sudo docker login --username=阿里云账号 registry.cn-hangzhou.aliyuncs.com
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
以上显示Login Succeeded,则代表登录成功
5.新增docker镜像
语法格式:
docker tag [ImageId] registry.cn-hangzhou.aliyuncs.com/docker2974/yang:[镜像版本号]
[root@yang ~]# docker tag f6d0b4767a6c registry.cn-hangzhou.aliyuncs.com/docker2974/yang:nginx1.0
[root@yang ~]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE nginx latest f6d0b4767a6c 2 weeks ago 133MB xiguajun/nginx3 2.0 f6d0b4767a6c 2 weeks ago 133MB registry.cn-hangzhou.aliyuncs.com/docker2974/yang nginx1.0 f6d0b4767a6c 2 weeks ago 133MB
6.上传(push)镜像到阿里云
语法格式:
docker push registry.cn-hangzhou.aliyuncs.com/docker2974/yang:[镜像版本号]
[root@yang ~]# docker push registry.cn-hangzhou.aliyuncs.com/docker2974/yang:nginx1.0 The push refers to repository [registry.cn-hangzhou.aliyuncs.com/docker2974/yang] 85fcec7ef3ef: Pushed 3e5288f7a70f: Pushed 56bc37de0858: Pushed 1c91bf69a08b: Pushed cb42413394c4: Pushed 1.0: digest: sha256:0b159cd1ee1203dad901967ac55eee18c24da84ba3be384690304be93538bea8 size: 1362
7.阿里云查看