Eug*_*erg 363 docker docker-registry
我有一个标记为me/my-image的docker图像,我在dockerhub上有一个名为me-private的私人仓库.当我推动我/我的形象时,我最终总是打到公共回购.
将图像专门推送到私人仓库的确切语法是什么?
Abd*_*aly 546
您需要先使用以下标记正确标记图像registryhost:
docker tag [OPTIONS] IMAGE[:TAG] [REGISTRYHOST/][USERNAME/]NAME[:TAG]
Run Code Online (Sandbox Code Playgroud)
然后docker使用相同的标签推送.
docker push NAME[:TAG]
Run Code Online (Sandbox Code Playgroud)
例:
docker tag 518a41981a6a myRegistry.com/myImage
docker push myRegistry.com/myImage
Run Code Online (Sandbox Code Playgroud)
Abh*_*pta 202
只需三个简单的步骤:
docker login --username username
--password
docker tag my-image username/my-repo
Gen*_*ene 42
首先转到Docker Hub帐户并进行回购.以下是我的Docker Hub帐户的屏幕截图:

从图片中,你可以看到我的回购是"chuangg"
现在进入回购并通过点击图片名称将其设为私有.所以对我来说,我点击了"chuangg/gene_commited_image",然后我去了设置 - >私有.然后我按照屏幕上的说明操作

如何将你的DOCKER图像上传到DOCKER HUB
方法#1 =通过命令行(cli)推送图像
1) docker commit <container ID> <repo name>/<Name you want to give the image>
是的,我认为它必须是容器ID.它可能不是图像ID.
例如= docker commit 99e078826312 chuangg/gene_commited_image
2) docker run -it chaung/gene_commited_image
3) docker login --username=<user username> --password=<user password>
例如= docker login --username=chuangg --email=gc.genechaung@gmail.com
是的,你必须先登录.使用"docker logout"注销
4) docker push chuangg/gene_commited_image
方法#2 =使用pom.xml和命令行推送映像.
注意,我使用了名为"build-docker"的Maven配置文件.如果您不想使用配置文件,只需删除<profiles>, <profile>, and <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>
Run Code Online (Sandbox Code Playgroud)
Docker Terminal命令用于部署Docker镜像(来自pom.xml所在的目录)= mvn clean deploy -Pbuild-docker docker:push
注意,方法#2和#3之间的区别在于方法#3有一个额外<execution>的部署.
方法#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>
Run Code Online (Sandbox Code Playgroud)
转到C:\ Users\Gene.docker \目录并将其添加到config.json文件中:

现在在您的Docker Quickstart终端类型= mvn clean install -Pbuild-docker
对于那些不使用Maven配置文件的人,只需输入即可 mvn clean install
这是我的完整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>
Run Code Online (Sandbox Code Playgroud)
这是我的Dockerfile:
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" ]
Run Code Online (Sandbox Code Playgroud)
错误#1的解决方案=不要<execution>与maven部署阶段同步,因为然后maven尝试部署映像2x并在jar上放置时间戳.这就是我使用的原因<phase>install</phase>.
Nic*_*rge 41
如果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>
Run Code Online (Sandbox Code Playgroud)
示例:
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
Run Code Online (Sandbox Code Playgroud)
Ken*_*ane 15
有两种选择:
进入集线器,首先创建存储库,并将其标记为私有.然后当你推到那个回购时,它将是私有的.这是最常用的方法.
登录您的docker hub帐户,然后转到您的全局设置.有一个设置允许您设置您推送的存储库的默认可见性.默认情况下,它设置为public,但如果将其更改为private,则默认情况下,您推送的所有存储库都将标记为private.请务必注意,您需要在帐户中提供足够的私人回购,否则在您升级计划之前,回购将会被锁定.
以下是将 Docker 镜像推送到 DockerHub 私有存储库的步骤
1-首先使用命令检查 Docker 镜像
docker images
2-查看 Docker Tag 命令帮助
docker tag --help
3-现在为您创建的图像标记一个名称
docker tag localImgName:tagName DockerHubUser\Private-repoName:tagName(标签名称是可选的。默认名称是latest)
4- 在将镜像推送到 DockerHub Private Repo 之前,首先使用命令登录 DockerHub
docker login[提供dockerHub用户名和密码登录]
5-现在使用命令将 Docker 镜像推送到您的私有存储库
docker push [options] ImgName[:tag]例如docker push DockerHubUser\Private-repoName:tagName
6-现在导航到 DockerHub Private Repo,您将看到 Docker 映像已推送到您的私有存储库上,名称在前面的步骤中写为 TagName
小智 7
> docker login [OPTIONS] [SERVER]
[OPTIONS]:
-u username
-p password
Run Code Online (Sandbox Code Playgroud)
例如:
> docker login localhost:8080
Run Code Online (Sandbox Code Playgroud)
> docker tag SOURCE_IMAGE[:TAG] TARGET_IMAGE[:TAG]
Run Code Online (Sandbox Code Playgroud)
例如:
> docker tag myApp:v1 localhost:8080/myname/myApp:v1
Run Code Online (Sandbox Code Playgroud)
>docker push [OPTIONS] NAME[:TAG]
Run Code Online (Sandbox Code Playgroud)
例如:
> docker push localhost:8080/myname/myApp:v1
Run Code Online (Sandbox Code Playgroud)
在dockerhub上创建存储库:
$docker tag IMAGE_ID UsernameOnDockerhub/repoNameOnDockerhub:latest
$docker push UsernameOnDockerhub/repoNameOnDockerhub:latest
注意:这里“ repoNameOnDockerhub”:dockerhub上必须存在您要提及的名称的存储库
“最新”:只是标签
当推送到Docker Hub帐户时,无论是公共帐户还是私有帐户,过程都是相同的。
OP 说:
我有一个标记为 me/my-image 的 docker 镜像,并且在 dockerhub 上有一个名为 me-private 的私有存储库。
当我推送我的我/我的形象时,我最终总是会访问公共仓库。
眼前的问题是私有存储库 ( me-private) 的名称似乎与映像 ( my-image) 的名称不同。存储库和图像必须具有相同的名称(减去任何标签)。
太长了;名为或 的
图像的存储库名称必须为。my-imagemy-image:tagmy-image
由于 OP 的存储库被命名为me-private,Docker Hub 不会将它们视为相同的,并且会创建名为 的新存储库my-image。
(默认情况下,新的存储库将是公开的,除非您更改设置以将所有存储库设为私有。)
截至 2022 年 6 月, 设置Docker Hub存储库的流程为:
给定以下值:
用户名 = 您的用户名
图片名称 = theimage
标签 = thetag
1)标记(或提交)本地图像,添加带有您的用户名的前缀:
docker tag theimage:thetag yourusername/theimage:thetag
Run Code Online (Sandbox Code Playgroud)
注意事项:
docker tag theimage:thetag yourusername/yourorganizationname/theimage:thetag
Run Code Online (Sandbox Code Playgroud)
latest,:thetag则可以省略部分;Docker 假设:latest如果你不输入:thetag一部分2)将带前缀的镜像推送到Docker Hub:
docker push yourusername/theimage:thetag
Run Code Online (Sandbox Code Playgroud)
或者
docker push yourusername/yourorganizationname/theimage:thetag
Run Code Online (Sandbox Code Playgroud)
对于私人存储库,需要执行以下额外步骤之一:
任何一个
在执行上述步骤 1 之前,在您的 Docker Hub 帐户中创建一个私有存储库
theimage请记住,存储库名称必须与您计划推送的存储库名称相同。不要包含thetag存储库名称的一部分。例如,如果您的图像是ubuntu:14.04,您可以将您的存储库命名为ubuntu。(所有标记的图像 - 例如ubuntu:latest,,ubuntu:14.04等 - 将进入ubuntu存储库。)
或者
如果您没有提前创建存储库(这不是必需的!):转到您在Docker Hub中的帐户;单击新推送的存储库,然后单击其“设置”选项卡 - 并将您的存储库设为私有。
小智 5
本主题提供有关部署和配置注册表的基本信息
在部署注册表之前,您需要在主机上安装Docker。
使用以下命令来启动注册表容器:
start_registry.sh
#!/bin/bash
docker run -d \
-p 5000:5000 \
--restart=always \
--name registry \
-v /data/registry:/var/lib/registry \
registry:2
Run Code Online (Sandbox Code Playgroud)
拉ubuntu:16.04离泊坞枢纽的形象。
$ docker pull ubuntu:16.04
Run Code Online (Sandbox Code Playgroud)将图像标记为localhost:5000/my-ubuntu。这将为现有图像创建一个附加标签。当标签的第一部分是主机名和端口时,推入时Docker会将其解释为注册表的位置。
$ docker tag ubuntu:16.04 localhost:5000/my-ubuntu
Run Code Online (Sandbox Code Playgroud)将映像推送到在以下位置运行的本地注册表localhost:5000:
$ docker push localhost:5000/my-ubuntu
Run Code Online (Sandbox Code Playgroud)删除本地缓存的图像。这不会localhost:5000/my-ubuntu从注册表中删除该图像。
$ docker image remove ubuntu:16.04
$ docker image remove localhost:5000/my-ubuntu
Run Code Online (Sandbox Code Playgroud)拉localhost:5000/my-ubuntu从本地注册表中的形象。
$ docker pull localhost:5000/my-ubuntu
Run Code Online (Sandbox Code Playgroud)根据docs.docker.com,这是非常不安全的,不建议这样做。
编辑daemon.json文件,其默认位置/etc/docker/daemon.json在Linux或C:\ProgramData\docker\config\daemon.jsonWindows Server上。如果使用Docker for Mac或Docker for Windows,请单击Docker icon -> Preferences -> Daemon,然后添加insecure registry。
如果daemon.json文件不存在,请创建它。假设文件中没有其他设置,则该文件应具有以下内容:
{
"insecure-registries" : ["myregistrydomain.com:5000"]
}
Run Code Online (Sandbox Code Playgroud)
启用不安全的注册表后,Docker会执行以下步骤:
重新启动Docker以使更改生效。
| 归档时间: |
|
| 查看次数: |
326069 次 |
| 最近记录: |