Search code examples
dockermavenwindows-10fabric8docker-desktop

can't build my own docker image using fabric8 maven plugin


I'm trying to build my own dokcer image based on a simple spring boot projet, using the fabric8 maven plugin, here is my configuration

<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>
        <plugin>
            <groupId>io.fabric8</groupId>
            <artifactId>docker-maven-plugin</artifactId>
            <version>0.33.0</version>

            <configuration>
                <dockerHost>tcp://localhost:2375</dockerHost>
                <verbose>true</verbose>
                <images>
                    <image>
                        <name>${docker.image.prefix}/${docker.image.name}</name>
                        <build>
                            <dockerFileDir>${project.basedir}/src/main/docker/</dockerFileDir>
                            <assembly>
                                <descriptorRef>artifact</descriptorRef>
                            </assembly>
                            <tags>
                                <tag>latest</tag>
                                <tag>${project.version}</tag>
                            </tags>
                        </build>
                    </image>
                </images>
            </configuration>
        </plugin>
    </plugins>
</build>

I'm exposing my docker doamon as suggested on other posts, but nothing works when i run this command line inside my Intellij

mvn clean package docker:run

enter image description here

I'm getting this stack trace

[INFO] --- docker-maven-plugin:0.33.0:run (default-cli) @ spring-boot-docker ---
[INFO] DOCKER> Credentials helper reply for "docker-credential-desktop" is 0.6.3
[ERROR] DOCKER> Error occurred during container startup, shutting down...
[ERROR] DOCKER> I/O Error [Unable to pull 'sofrateam/springbootdocker:latest' : {"message":"pull access denied for sofrateam/springbootdocker, repository does not exist or may require 'docker login': denied: re
quested access to the resource is denied"} (Not Found: 404)]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  12.442 s
[INFO] Finished at: 2020-04-21T09:56:15+02:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal io.fabric8:docker-maven-plugin:0.33.0:run (default-cli) on project spring-boot-docker: I/O Error: Unable to pull 'sofrateam/springbootdocker:latest' : {"message":"pull access deni
ed for sofrateam/springbootdocker, repository does not exist or may require 'docker login': denied: requested access to the resource is denied"} (Not Found: 404) -> [Help 1]

Do i need to create a local docker hub on my machine ( Docker Desktop). The probleme is that when i use the command line window CMD, and i go where the docker file exist and i run the command line

docker build -t sofrateam/springbootdocker .

It works correctly , the image appear in the list of images inside my docker desktop !!! why whit maven plugin and the docker host filed is's not working ??


Solution

  • i changed the goal to build instead of run and every thing turns OK

    mvn clean package docker:build docker:run
    

    with this command, docker build wil create my image and put it to my local docker hub, then when docker run is performed the image will be alreay on my local docker so i can satart my container from that image

    1. docker build
    2. docker run