de-vraag
  • 疑问
  • 标签
  • 用户
通知
奖励
注册
一旦您注册,您将会收到对您的问题的回复和评论。
登录
如果您已经有一个账户,请登录查看新的通知。
增加的问题、答案和评论会有奖励。
更多
资料来源
编辑
Eugene Goldberg
Eugene Goldberg
问题

如何推送docker镜像到私有仓库

我有一个标记为me/my-image的docker镜像,我在dockerhub上有一个名为me-private的私有 repo。 当我推送me/my-image的时候,我最终总是撞到公共 repo。

要把我的图像推送到我的私人 repo,具体的语法是什么?

362 2015-02-05T16:42:49+00:00 9
Valeriu
Valeriu 50848
已编辑的问题 5日 十月 2021 в 8:41
 luchaninov
luchaninov
已编辑的问题 27日 五月 2016 в 9:14
编程
docker
docker-registry
热门视频
Docker 19 Docker私有仓库镜像上传
Docker 19 Docker私有仓库镜像上传
2年前
上传docker容器镜像到dockerhub
上传docker容器镜像到dockerhub
1年前
16 Docker  获取和推送镜像
16 Docker 获取和推送镜像
3年前
第七章 docker私有仓库 第一节 搭建
第七章 docker私有仓库 第一节 搭建
10个月前
docker入门:容器、镜像、仓库介绍
docker入门:容器、镜像、仓库介绍
1年前
33 尚硅谷 Docker 本地镜像推送到阿里云
33 尚硅谷 Docker 本地镜像推送到阿里云
3年前
87 Docker与微服务实战 Portainer简介和安装
87 Docker与微服务实战 Portainer简介和安装
4个月前
35 Docker与微服务实战 tomcat安装上集
35 Docker与微服务实战 tomcat安装上集
4个月前
使用Docker快速部署NextCloud
使用Docker快速部署NextCloud
10个月前
28 Docker与微服务实战 新镜像推送私服库案例
28 Docker与微服务实战 新镜像推送私服库案例
4个月前
Docker 18 Docker私有仓库的搭建与配置
Docker 18 Docker私有仓库的搭建与配置
2年前
36 Docker与微服务实战 tomcat安装下集
36 Docker与微服务实战 tomcat安装下集
4个月前
37 Docker与微服务实战 mysql安装上集
37 Docker与微服务实战 mysql安装上集
4个月前
Openwrt Docker 镜像 安装详细过程实现科学上网,没有设备也可以体验|软路由|旁路网关
Openwrt Docker 镜像 安装详细过程实现科学上网,没有设备也可以体验|软路由|旁路网关
8个月前
« 前进
下一步 »
解决方案/答案
Abdullah Jibaly
Abdullah Jibaly
5日 二月 2015 в 4:49
2015-02-05T16:49:10+00:00
更多
资料来源
编辑
#26711889

你需要先用你的 "registryhost "正确标记你的图片。

docker tag [OPTIONS] IMAGE[:TAG] [REGISTRYHOST/][USERNAME/]NAME[:TAG]

然后使用相同的标签进行docker推送。

docker push NAME[:TAG]

例子。

docker tag 518a41981a6a myRegistry.com/myImage
docker push myRegistry.com/myImage
 MiniGod
MiniGod
编辑本段答案14日 七月 2017 в 4:36
544
0
Abhishek Dasgupta
Abhishek Dasgupta
22日 五月 2017 в 9:16
2017-05-22T09:16:44+00:00
更多
资料来源
编辑
#26711892

只需简单的三步。

  1. docker login --username username。
  • 如果你省略了--password,就会提示你输入密码,建议这样做,因为它不会存储在你的命令历史中。
  1. docker tag my-image username/my-repo。

  2. docker push username/my-repo。

 SomeGuyOnAComputer
SomeGuyOnAComputer
编辑本段答案20日 十一月 2019 в 3:03
202
0
 Gene
Gene
1日 十二月 2016 в 7:07
2016-12-01T19:07:01+00:00
更多
资料来源
编辑
#26711891

首先进入你的Docker Hub账户,制作 repo。下面是我的Docker Hub账户的截图。 ![在此输入图片描述][1] 。

从图片中,你可以看到我的 repo 是 "chuangg"。

现在进入 repo,通过点击你的图像名称使其成为私有。对我来说,我点击了 "chuangg/gene_commited_image",然后我进入设置-> 使之成为私有。然后我按照屏幕上的指示 ![在此输入图像描述][2] 。

如何将你的docker镜像上传到docker hub?

方法#1=通过命令行(cli)推送你的镜像

  1. docker commit <container ID> <repo name>/<你想给镜像的名字>。

是的,我认为它必须是容器ID。它可能不能是镜像的ID。

例如= docker commit 99e078826312 chuangg/gene_commited_image。

  1. docker run -it chaung/gene_commited_image。

  2. docker login --username=<user username> --password=<user password>。

例如= docker login --username=chuangg [email protected]。

是的,你必须先登录。使用 "docker logout "注销

  1. docker push chuangg/gene_commited_image。

**方法#2=使用pom.xml和命令行推送你的图像。

注意,我使用了一个名为 "build-docker "的Maven配置文件。如果你不想使用配置文件,只需删除<profiles>、<profile>和<id>build-docker</id>元素。

在父级的pom.xml里面。

<profiles>
        <profile>
            <id>build-docker</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>io.fabric8</groupId>
                        <artifactId>docker-maven-plugin</artifactId>
                        <version>0.18.1</version>
                        <configuration>
                            <images>
                                <image>
                                    <name>chuangg/gene_project</name>
                                    <alias>${docker.container.name}</alias>
                                    <!-- Configure build settings -->
                                    <build>
                                        <dockerFileDir>${project.basedir}\src\docker\vending_machine_emulator</dockerFileDir>
                                        <assembly>
                                            <inline>
                                                <fileSets>
                                                    <fileSet>
                                                        <directory>${project.basedir}\target</directory>
                                                        <outputDirectory>.</outputDirectory>
                                                        <includes>
                                                            <include>*.jar</include>
                                                        </includes>
                                                    </fileSet>
                                                </fileSets>
                                            </inline>
                                        </assembly>
                                    </build>
                                </image>
                            </images>
                        </configuration>
                        <executions>
                            <execution>
                                <id>docker:build</id>
                                <phase>package</phase>
                                <goals>
                                    <goal>build</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>

部署Docker镜像的Docker终端命令(从pom.xml所在的目录)= mvn clean deploy -Pbuild-docker docker:push。

注意,方法#2和#3的区别是,方法#3有一个额外的<执行>用于部署。

方法#3=使用Maven自动部署到Docker Hub。

把这些东西添加到你的父级pom.xml中。

    <distributionManagement>
        <repository>
            <id>gene</id>
            <name>chuangg</name>
            <uniqueVersion>false</uniqueVersion>
            <layout>legacy</layout>
            <url>https://index.docker.io/v1/</url>
        </repository>
    </distributionManagement>

    <profiles>
        <profile>
            <id>build-docker</id>
            <build>
                <plugins>

                    <plugin>
                        <groupId>io.fabric8</groupId>
                        <artifactId>docker-maven-plugin</artifactId>
                        <version>0.18.1</version>
                        <configuration>
                            <images>
                                <image>
                                    <name>chuangg/gene_project1</name>
                                    <alias>${docker.container.name}</alias>
                                    <!-- Configure build settings -->
                                    <build>
                                        <dockerFileDir>${project.basedir}\src\docker\vending_machine_emulator</dockerFileDir>
                                        <assembly>
                                            <inline>
                                                <fileSets>
                                                    <fileSet>
                                                        <directory>${project.basedir}\target</directory>
                                                        <outputDirectory>.</outputDirectory>
                                                        <includes>
                                                            <include>*.jar</include>
                                                        </includes>
                                                    </fileSet>
                                                </fileSets>
                                            </inline>
                                        </assembly>
                                    </build>
                                </image>
                            </images>
                        </configuration>
                        <executions>
                            <execution>
                                <id>docker:build</id>
                                <phase>package</phase>
                                <goals>
                                    <goal>build</goal>
                                </goals>
                            </execution>
                            <execution>
                                <id>docker:push</id>
                                <phase>install</phase>
                                <goals>
                                    <goal>push</goal>
                                </goals>
                            </execution>

                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
</project>

到C:\Users\Gene.docker\目录,把这个添加到你的config.json文件。 ![在此输入图片描述][3] 。

现在在你的Docker快速启动终端键入= mvn clean install -Pbuild-docker。

对于没有使用Maven Profiles的用户,只需输入mvn clean install即可。

以下是成功信息的截图。 ![在此输入图片描述][4] 。

这是我的完整pom.xml和目录结构的截图。

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>com.gene.app</groupId>
<artifactId>VendingMachineDockerMavenPlugin</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>

<name>Maven Quick Start Archetype</name>
<url>www.gene.com</url>

<build>
    <pluginManagement>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <configuration>
                    <archive>
                        <manifest>
                            <mainClass>com.gene.sample.Customer_View</mainClass>
                        </manifest>
                    </archive>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.1</version>
                <configuration>

                    <source>1.7</source>
                    <target>1.7</target>

                </configuration>
            </plugin>
        </plugins>
    </pluginManagement>
</build>

<dependencies>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.8.2</version>
        <scope>test</scope>
    </dependency>

</dependencies>

<distributionManagement>
    <repository>
        <id>gene</id>
        <name>chuangg</name>
        <uniqueVersion>false</uniqueVersion>
        <layout>legacy</layout>
        <url>https://index.docker.io/v1/</url>
    </repository>
</distributionManagement>

<profiles>
    <profile>
        <id>build-docker</id>
        <properties>
            <java.docker.version>1.8.0</java.docker.version>
        </properties>
        <build>
            <plugins>

                <plugin>
                    <groupId>io.fabric8</groupId>
                    <artifactId>docker-maven-plugin</artifactId>
                    <version>0.18.1</version>
                    <configuration>
                        <images>
                            <image>
                                <name>chuangg/gene_project1</name>
                                <alias>${docker.container.name}</alias>
                                <!-- Configure build settings -->
                                <build>
                                    <dockerFileDir>${project.basedir}\src\docker\vending_machine_emulator</dockerFileDir>
                                    <assembly>
                                        <inline>
                                            <fileSets>
                                                <fileSet>
                                                    <directory>${project.basedir}\target</directory>
                                                    <outputDirectory>.</outputDirectory>
                                                    <includes>
                                                        <include>*.jar</include>
                                                    </includes>
                                                </fileSet>
                                            </fileSets>
                                        </inline>
                                    </assembly>
                                </build>
                            </image>
                        </images>
                    </configuration>
                    <executions>
                        <execution>
                            <id>docker:build</id>
                            <phase>package</phase>
                            <goals>
                                <goal>build</goal>
                            </goals>
                        </execution>
                        <execution>
                            <id>docker:push</id>
                            <phase>install</phase>
                            <goals>
                                <goal>push</goal>
                            </goals>
                        </execution>

                    </executions>
                </plugin>
            </plugins>
        </build>
    </profile>
</profiles>
这是我的Eclipse目录。 [![在此输入图片描述][6]][6] 。

这里是我的Docker文件。

FROM java:8

MAINTAINER Gene Chuang
RUN echo Running Dockerfile in src/docker/vending_machine_emulator/Dockerfile directory

ADD maven/VendingMachineDockerMavenPlugin-1.0-SNAPSHOT.jar /bullshitDirectory/gene-app-1.0-SNAPSHOT.jar 

CMD ["java", "-classpath", "/bullshitDirectory/gene-app-1.0-SNAPSHOT.jar", "com/gene/sample/Customer_View" ] 

常见错误#1。 在此输入图片描述 。

错误#1的解决方案= 不要将<执行>与maven部署阶段同步,因为这样maven就会尝试部署2倍的镜像,并在jar上加一个时间戳。这就是为什么我使用<阶段>安装</阶段>。

 Community
Community
编辑本段答案18日 七月 2017 в 3:07
42
0
Nicolas Delaforge
Nicolas Delaforge
25日 七月 2017 в 8:32
2017-07-25T20:32:36+00:00
更多
资料来源
编辑
#26711893

如果你的docker注册表是私有的,并且是自我托管的,你应该做以下工作。

docker login <REGISTRY_HOST>:<REGISTRY_PORT>
docker tag <IMAGE_ID> <REGISTRY_HOST>:<REGISTRY_PORT>/<APPNAME>:<APPVERSION>
docker push <REGISTRY_HOST>:<REGISTRY_PORT>/<APPNAME>:<APPVERSION>

例:

docker login repo.company.com:3456
docker tag 19fcc4aa71ba repo.company.com:3456/myapp:0.1
docker push repo.company.com:3456/myapp:0.1

。

docker login repo.company.com:3456
docker tag 19fcc4aa71ba repo.company.com:3456/myapp:0.1
docker push repo.company.com:3456/myapp:0.1
41
0
Ken Cochrane
Ken Cochrane
29日 五月 2015 в 3:06
2015-05-29T15:06:02+00:00
更多
资料来源
编辑
#26711890

有两个选择。

1.进入中心,先创建版本库,并将其标记为私有。然后当你推送到该版本时,它将是私有的。这是最常见的方法。

2.登录你的docker hub账户,并进入你的全局设置。有一个设置允许你设置你推送的仓库的默认可见性。默认情况下,它被设置为公开,但如果你把它改为私有,你推送的所有仓库都会被默认标记为私有。值得注意的是,你需要在你的账户上有足够的私有仓库,否则仓库将被锁定,直到你升级你的计划。

Docker Hub
registry.hub.docker.com
15
0
Anurag Manikkame
Anurag Manikkame
7日 十二月 2018 в 10:07
2018-12-07T10:07:05+00:00
更多
资料来源
编辑
#26711897

在dockerhub上创建仓库。

$docker tag IMAGE_ID UsernameOnDockerhub/repoNameOnDockerhub:last。

$docker push UsernameOnDockerhub/repoNameOnDockerhub:last。

注:这里。 "repoNameOnDockerhub&quot。 : 您所提到的名称的仓库有 在dockerhub上出现

"最新&quot。
只是标签
Anurag Manikkame
Anurag Manikkame
编辑本段答案7日 十二月 2018 в 12:26
7
0
David Ding
David Ding
21日 五月 2018 в 2:12
2018-05-21T02:12:49+00:00
更多
资料来源
编辑
#26711896

参考文献: [dock.docker.com]() dock.docker.com

本主题提供了有关部署和配置注册表的基本信息。

运行本地注册表

在部署注册表之前,你需要在主机上安装Docker。

使用类似下面的命令来启动注册表容器。

start_registry.sh

#!/bin/bash

docker run -d \
  -p 5000:5000 \
  --restart=always \
  --name registry \
  -v /data/registry:/var/lib/registry \
  registry:2

从Docker Hub复制一个镜像到你的注册表中。

  1. 从Docker Hub中拉出ubuntu:16.04镜像。

$ docker pull ubuntu:16.04

  1. 将镜像标记为localhost:5000/my-ubuntu。 这将为现有的镜像创建一个额外的标签。 当标签的第一部分是主机名和端口时,Docker在推送时将其解释为注册表的位置。

$ docker tag ubuntu:16.04 localhost:5000/my-ubuntu

  1. 将镜像推送到运行在localhost:5000的本地注册表。

$ docker push localhost:5000/my-ubuntu

  1. 删除本地缓存的镜像。 这不会从注册表中删除localhost:5000/my-ubuntu镜像。

$ docker image remove ubuntu:16.04 $ docker image remove localhost:5000/my-ubuntu

  1. 从本地注册表中拉出localhost:5000/my-ubuntu镜像。

$ docker pull localhost:5000/my-ubuntu

部署一个普通的HTTP注册表。

根据docs.docker.com,这是非常不安全的,不建议**。

  1. 编辑daemon.json文件,在Linux上,它的默认位置是/etc/docker/daemon.json,在Windows Server上,它的默认位置是C:/\ProgramData/docker\config\daemon.json。 如果你使用Docker for Mac或Docker for Windows,点击Docker图标-&gt。 Preferences -> Daemon,在insecure注册表中添加。

如果daemon.json文件不存在,就创建它。 假设文件中没有其他设置,它应该有以下内容。

{ "不安全的注册&quot。 : ["myregistrydomain.com:5000"] }

在启用了不安全注册表的情况下,Docker会经过以下步骤。

  • 首先,尝试使用HTTPS。
  • 如果HTTPS可用,但证书无效,忽略关于证书的错误。
  • 如果HTTPS不可用,则退回到HTTP。
  1. 重新启动Docker,让更改生效。
Deploy a registry server | Docker Documentation
Explains how to deploy a registry
docs.docker.com
Test an insecure registry | Docker Documentation
Deploying a Registry in an insecure fashion
docs.docker.com
5
0
 crane-yuan
crane-yuan
1日 九月 2017 в 3:39
2017-09-01T03:39:24+00:00
更多
资料来源
编辑
#26711894

首先登录你的私人仓库。

> docker login [OPTIONS] [SERVER]

[OPTIONS]: 
-u username 
-p password

例如:

> docker login localhost:8080

。

> docker login localhost:8080

然后在你的私人仓库中标记你的图片。

> docker tag SOURCE_IMAGE[:TAG] TARGET_IMAGE[:TAG]

例如:

> docker tag myApp:v1 localhost:8080/myname/myApp:v1

。

> docker tag myApp:v1 localhost:8080/myname/myApp:v1

最后将你的aged图片推送到你的私人仓库中。

>docker push [OPTIONS] NAME[:TAG]

例如:

> docker push localhost:8080/myname/myApp:v1

。

> docker push localhost:8080/myname/myApp:v1

参考资料

  • [docker命令参考][1]

[1]: https://docs.docker.com/engine/reference/commandline/cli/

Use the Docker command line | Docker Documentation
Docker&#39;s CLI command description and usage
docs.docker.com
4
0
 Dung
Dung
16日 九月 2017 в 6:48
2017-09-16T06:48:07+00:00
更多
资料来源
编辑
#26711895

简单的工作解决方案。

到这里https://hub.docker.com/创建一个PRIVATE repository,名称比如johnsmith/private-repository这就是你在构建镜像时要用到的NAME/REPOSITORY。

  • 首先,"docker登录"。

  • 其次,我使用"docker build -t johnsmith/private-repository:01 ." (其中01是我的版本名)来创建镜像,然后我使用"docker images" 来确认创建的镜像,比如下面这个黄框。 (抱歉,我不能粘贴表格格式,只能粘贴文本字符串)

&gt.Johnsmith/privaterepository(repository)01(TAG)c5f4a2861d6(IMAGE ID)2天前(CREATED 305MB(SIZE))。 johnsmith/private-repository(REPOSITORY) 01(TAG) c5f4a2861d6e(IMAGE ID) 2天前(CREATED) 305MB(SIZE)

  • 第三,我使用docker push johnsmith/private-repository:01(你的私有仓库将在这里,例如https://hub.docker.com/r/johnsmith/private-repository/)。

好了!

 Dung
Dung
编辑本段答案18日 九月 2017 в 3:07
3
0
添加问题
岚,巗峃,。
全部
技术
文化/娱乐
生活/艺术
科学
专业的
业务
用户
全部
新的
热门
1
mohidil qodirova
注册1天前
2
Jasur Fozilov
注册1天前
3
Zuxriddin Muydinov
注册2天前
4
Денис Анненский
注册4天前
5
365
注册1周前
BG
DE
EL
ES
FR
ID
IT
JA
KO
NL
PT
RU
TR
ZH
© de-vraag 2022
资料来源
stackoverflow.com
特许 cc by-sa 3.0 有功