Подтвердить что ты не робот

Нажатие докерного изображения на докер-хаб

Я создал свой собственный файл докеров (который запускает оболочку script, которая печатает "helloworld" ). Изображение "hellodocker", а тег - "mytag", Теперь у меня есть:

bash-3.2$ docker images
REPOSITORY          TAG                   IMAGE ID            CREATED                 VIRTUAL SIZE
hellodocker         mytag                 3514c8dc11a8        39 minutes ago      2.433 MB
busybox             buildroot-2013.08.1   d200959a3e91        10 weeks ago        2.489 MB
busybox             ubuntu-14.04          37fca75d01ff        10 weeks ago        5.609 MB
busybox             ubuntu-12.04          fd5373b3d938        10 weeks ago        5.455 MB
busybox             buildroot-2014.02     a9eb17255234        10 weeks ago        2.433 MB
busybox             latest                a9eb17255234        10 weeks ago        2.433 MB

docker ps -a
CONTAINER ID        IMAGE                       COMMAND                CREATED             STATUS                        PORTS               NAMES
97c29510069e        hellodocker:mytag           /bin/sh -c /Users/in   33 minutes ago                  Exited (127) 26 minutes ago                       happy_pasteur       
8d04a1385c24        hellodocker:mytag           /bin/sh -c /Users/in   37 minutes ago      Exited (127) 30 minutes ago                       mad_bell            
8998d61c0513        hellodocker:mytag           /bin/sh -c /Users/in   37 minutes ago      Exited (127) 30 minutes ago                       boring_thompson         
64314c304a29        hellodocker:mytag           /bin/sh -c /Users/in   37 minutes ago      Exited (127) 31 minutes ago                       sad_wilson          
8bc20e0555b8        hellodocker:mytag           /bin/sh -c /Users/in   38 minutes ago      Exited (127) 31 minutes ago                       sleepy_mayer        
97664a4ba870        hellodocker:mytag           .                      38 minutes ago                                                        kickass_poincare    
8bb752631cb6        busybox:buildroot-2014.02   /bin/echo Hello Doct   18 hours ago        Exited (0) 18 hours ago                           dreamy_kowalevski   
6aa66b55ca94        busybox:buildroot-2014.02   bash-3.2$ sudo docke   18 hours ago                                                          ecstatic_lovelace   
2cc657f65342        busybox:buildroot-2014.02   /bin/echo Hello Dock   18 hours ago        Exited (0) 18 hours ago                           dreamy_poincare 

Как мне нажимать изображение докеров на докер-хаб? Я использую docker push <myuserid>/hellodocker. Это дает ошибку "нет такой ошибки". Что мне не хватает? Спасибо заранее.

4b9b3361

Ответ 1

Вам нужно пометить его как <myuser>/hellodocker при его создании, e g

docker build -t <myuser>/hellodocker:mytag .

или создать новый тег, привязанный к тому же изображению, я e

docker tag hellodocker:mytag <myuser>/hellodocker:mytag

Ответ 2

Если вы хотите разместить репозиторий hellodocker в пространстве имен myuserid, вы должны сначала пометить локальный hellodocker на myuserid как:

docker tag hellodocker myuserid/hellodocker

И затем нажмите этот репозиторий myuserid/hellodocker на концентратор, например:

Докерный толчок myuserid/hellodocker

Ответ 3

Сначала перейдите на свою учетную запись Docker Hub и сделайте репо. Вот скриншот моей учетной записи Docker Hub: введите описание изображения здесь

Из рисунка вы можете видеть, что мое репо - "chuangg"

КАК ЗАГРУЗИТЬ ВАШЕ ПРОСМОТР ИЗОБРАЖЕНИЯ НА ДОЛЖНОМ ДОКУМЕНТЕ

Метод # 1 = Нажатие изображения через командную строку (cli)

1) docker commit <container ID> <repo name>/<Name you want to give the image>

Да, я думаю, что это должен быть идентификатор контейнера. Вероятно, это не может быть идентификатор изображения.

Например = docker commit 99e078826312 chuangg/gene_commited_image

2) docker run -it chaung/gene_commited_image

3) docker login --username=<user username> --email=<user email address>

Например = docker login --username=chuangg [email protected]

Да, сначала вам нужно войти в систему. Выход из системы с помощью "выхода из докера"

4) docker push chuangg/gene_commited_image

Метод # 2 = Нажатие изображения с помощью pom.xml и командной строки.

Примечание. Я использовал профиль Maven под названием "build-docker". Если вы не хотите использовать профиль, просто удалите элементы <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>

Команда Docker Terminal для развертывания Docker Image (из каталога, где находится ваш pom.xml) = mvn clean deploy -Pbuild-docker docker:push

Для тех из вас, кто не использует профиль Maven, команда будет просто mvn clean deploy 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>

Перейдите в каталог C:\Users\Gene.docker\и добавьте его в файл config.json: введите описание изображения здесь

Теперь в вашем терминале быстрого запуска Docker = mvn clean install -Pbuild-docker

Для тех из вас, кто не использует профиль, просто введите 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>

Вот мой каталог Eclipse: введите описание изображения здесь

Вот мой файл 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 = Не синхронизировать <execution> с фазой развертывания maven, потому что тогда maven пытается развернуть изображение 2x и помещает метку времени на банку. Вот почему я использовал <phase>install</phase>.