本文主要是介绍将docker镜像push到docker hub,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
1、登录到docker hub (docker hub注册网址:https://hub.docker.com)
#docker login
Username: rhl (docker hub上注册的账号)
Password: (docker hub上所注册账号的密码)
2、使用docker tag 命令为本地镜像添加新的标签
#docker tag image1:latest(本地镜像)rhl/image1:latest(新添加的镜像)
3、使用docker push 命令将新添加的镜像上传到docker hub
#docker push rhl/image1:latest
4、完成
以下实例为将两个镜像push 到docker hub上。
Maxwell@LAPTOP-KPU1SM6A MINGW64 /c/software/SpringCloud/202107/spring-cloud-progress-1 (master)
$ docker login
Authenticating with existing credentials...
Login Succeeded
Maxwell@LAPTOP-KPU1SM6A MINGW64 /c/software/SpringCloud/202107/spring-cloud-progress-1 (master)
$ docker tag config-server:latest maxwell12306/^C
Maxwell@LAPTOP-KPU1SM6A MINGW64 /c/software/SpringCloud/202107/spring-cloud-progress-1 (master)
$ dcoker tag config-server:latest maxwell12306/config-server:latest
bash: dcoker: command not found
Maxwell@LAPTOP-KPU1SM6A MINGW64 /c/software/SpringCloud/202107/spring-cloud-progress-1 (master)
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
c0eefc255547 config-server:0.1 "java -jar /app.jar" About an hour ago Up About an hour 0.0.0.0:8888->8888/tcp, :::8888->8888/tcp config-server
fd59bc2420b3 config-client:0.1 "java -jar /app.jar" About an hour ago Up About an hour 0.0.0.0:8003->8003/tcp, :::8003->8003/tcp config-client
Maxwell@LAPTOP-KPU1SM6A MINGW64 /c/software/SpringCloud/202107/spring-cloud-progress-1 (master)
$ dcoker tag config-server:0.1 maxwell12306/config-server:0.1
bash: dcoker: command not found
Maxwell@LAPTOP-KPU1SM6A MINGW64 /c/software/SpringCloud/202107/spring-cloud-progress-1 (master)
$ docker tag config-server:0.1 maxwell12306/config-server
Maxwell@LAPTOP-KPU1SM6A MINGW64 /c/software/SpringCloud/202107/spring-cloud-progress-1 (master)
Maxwell@LAPTOP-KPU1SM6A MINGW64 /c/software/SpringCloud/202107/spring-cloud-progress-1 (master)
$ docker tag config-client:0.1 maxwell12306/config-client
Maxwell@LAPTOP-KPU1SM6A MINGW64 /c/software/SpringCloud/202107/spring-cloud-progress-1 (master)
Maxwell@LAPTOP-KPU1SM6A MINGW64 /c/software/SpringCloud/202107/spring-cloud-progress-1 (master)
$ docker push maxwell12306/config-server
Using default tag: latest
The push refers to repository [docker.io/maxwell12306/config-server]
eefbe040d82b: Preparing
dd8757cf1f05: Preparing
92c0f688f4d5: Preparing
b44cbf3e6b88: Preparing
fe6a4fdbedc0: Preparing
e4d0e810d54a: Preparing
4e006334a6fd: Preparing
e4d0e810d54a: Waiting
4e006334a6fd: Waiting
92c0f688f4d5: Pushed
b44cbf3e6b88: Pushed
fe6a4fdbedc0: Pushed
e4d0e810d54a: Pushed
eefbe040d82b: Pushed
dd8757cf1f05: Pushed
4e006334a6fd: Pushed
latest: digest: sha256:276131a86d5d8c15d970eead095bfb12a4aa7d4ae43ad2edbe307290a4f4871d size: 1793
Maxwell@LAPTOP-KPU1SM6A MINGW64 /c/software/SpringCloud/202107/spring-cloud-progress-1 (master)
$ docker push maxwell12306/config-client
Using default tag: latest
The push refers to repository [docker.io/maxwell12306/config-client]
627d77ee29ea: Preparing
dd8757cf1f05: Preparing
92c0f688f4d5: Preparing
b44cbf3e6b88: Preparing
fe6a4fdbedc0: Preparing
e4d0e810d54a: Preparing
4e006334a6fd: Preparing
e4d0e810d54a: Waiting
92c0f688f4d5: Mounted from maxwell12306/config-server
b44cbf3e6b88: Mounted from maxwell12306/config-server
fe6a4fdbedc0: Mounted from maxwell12306/config-server
dd8757cf1f05: Mounted from maxwell12306/config-server
e4d0e810d54a: Mounted from maxwell12306/config-server
4e006334a6fd: Mounted from maxwell12306/config-server
627d77ee29ea: Pushed
latest: digest: sha256:8bda2cd4883acc95eebfacbf775b8d52bc22d6e597b734352cb39b3276b88254 size: 1793
Maxwell@LAPTOP-KPU1SM6A MINGW64 /c/software/SpringCloud/202107/spring-cloud-progress-1 (master)
$
这篇关于将docker镜像push到docker hub的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!