发布自己的镜像
- Docker Hub
1、地址 https://hub.docker.com/ 注册自己的账号
2、确定这个账号可以登录
3、在我们服务器上提交自己的镜像
[root@zhujixiang test]# docker login --help
Usage: docker login [OPTIONS] [SERVER]
Log in to a Docker registry.
If no server is specified, the default is defined by the daemon.
Options:
-p, --password string Password
--password-stdin Take the password from stdin
-u, --username string Username
[root@zhujixiang test]# docker login -u zhujixiang
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
4、登录完成之后就可以提交镜像, docker push
# push 自己的镜像到服务器上!
[root@zhujixiang test]# docker push diytomcat
The push refers to repository [docker.io/library/diytomcat]
3a02a0776427: Preparing
11d7a8a3b421: Preparing
c2a694ec3a21: Preparing
37536a3ebcbf: Preparing
0683de282177: Preparing
denied: requested access to the resource is denied # 拒绝
# push 镜像时的问题
[root@zhujixiang ~]# docker push zhujixiang/diytomcat:1.0
The push refers to repository [docker.io/zhujixiang/diytomcat]
An image does not exist locally with the tag: zhujixiang/diytomcat
# 解决:增加一个 tag
[root@zhujixiang tomcat]# docker tag b486e49426fd zhujixiang/tomcat:1.0
[root@zhujixiang tomcat]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
diytomcat latest b486e49426fd 34 seconds ago 636MB
zhujixiang/tomcat 1.0 b486e49426fd 34 seconds ago 636MB
nginx latest 4392e5dad77d 9 days ago 132MB
mysql 5.7 a4fdfd462add 3 weeks ago 448MB
centos latest 470671670cac 4 months ago 237MB
# docker push 上去即可,push 的时候尽量带上版本号!
[root@zhujixiang tomcat]# docker push zhujixiang/tomcat:1.0
提交的时候也是按照镜像的层级来进行提交的!
- 阿里云镜像服务上
1、登录阿里云
2、找到容器镜像服务
3、创建命名空间
4、创建容器镜像
5、浏览页面信息
阿里云官方文档:https://cr.console.aliyun.com/repository/cn-hangzhou/zhujixiang-test/zhujixiang-aliyun/details
超级详细!
PS:我只是一个刚刚开始学习 Docker 的小白,学习源自B站 遇见狂神说