1、首先在Docker-hub注册自己的账号信息。
https://hub.docker.com/
2、你需要在本机上使用 docker login 命令,用刚才注册的用户名和密码认证身份登录,像这里就用了我的用户名“systanx”:
harbo@harbo-virtual-machine:~$ docker login -u systanx
Password:
WARNING! Your password will be stored unencrypted in /home/harbo/.docker/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-store
Login Succeeded
3、第三步很关键,需要使用 docker tag 命令,给镜像改成带用户名的完整名字,表示镜像是属于这个用户的。或者简单一点,直接用 docker build -t 在创建镜像的时候就起好名字。
格式:
docker tag SOURCE_IMAGE[:TAG] TARGET_IMAGE[:TAG]
举例
docker tag redis:3.15 systanx/redis:3.5
源镜像:标签 用户名/镜像:标签
4、查看仓库下,修改的镜像是否存在是
harbo@harbo-virtual-machine:~$ docker tag alpine:3.15 systanx/redis:3.15
harbo@harbo-virtual-machine:~$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
redis latest 2e50d70ba706 7 days ago 117MB
busybox latest 62aedd01bd85 3 weeks ago 1.24MB
ubuntu 18.04 ad080923604a 3 weeks ago 63.1MB
alpine latest e66264b98777 5 weeks ago 5.53MB
alpine 3.15 0ac33e5f5afa 2 months ago 5.57MB
systanx/redis 3.15 0ac33e5f5afa 2 months ago 5.57MB
hello-world latest feb5d9fea6a5 9 months ago 13.3kB
5、然后将这个修改的镜像推到docker-hub上面
docker push systanx/redis:3.15
harbo@harbo-virtual-machine:~$ docker tag redis:latest systanx/redis.3.15
harbo@harbo-virtual-machine:~$ docker push systanx/redis.3.15
Using default tag: latest
The push refers to repository [docker.io/systanx/redis.3.15]
be56018ff479: Pushed
58bcc523fc92: Pushed
4ca33072d026: Pushed
cf3ae502d7fa: Pushed
5659b3a1146e: Pushed
08249ce7456a: Pushed
latest: digest: sha256:31120dcdd310e9a65cbcadd504f4fe60a185bd634ab7c6a35e3e44a941904d97 size: 1573
6、然后到docker-hub网站查看自己的仓库是否有上传的镜像数据
7、如果在上传的过程当中出现了权限拒绝等现象,请检查用户名
检查用户名是否错误【systanx】/redis.2.15
harbo@harbo-virtual-machine:~$ docker push systanx/redis.2.15
Using default tag: latest
The push refers to repository [docker.io/systanx/redis.2.15]
be56018ff479: Preparing
58bcc523fc92: Preparing
4ca33072d026: Preparing
cf3ae502d7fa: Preparing
5659b3a1146e: Preparing
08249ce7456a: Waiting
denied: requested access to the resource is denied