Docker image is not listed though I built using maven docker plugin

1.2k views Asked by At

I have built docker image using following command. (Used com.spotify:docker-maven-plugin:0.3.3 maven plugin). I am using Docker Tool Box in Windows.

mvn clean package docker:build

It gave SUCCESS with following description.

Successfully built d27ae98a8879
[INFO] Built localhost/my-tt-server
[INFO] Tagging localhost/my-tt-server with 1.1.x-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------

After this, if I run 'docker ps -a', it should have displayed this new image. But I am not seeing any image related to this. Hence I am not able to start/run the new image.

I am not able to run 'docker-compose up my-tt-server' using following configuration in docker-compose.yml

my-tt-server:
  container_name: my-tt-server
  image: localhost/my-tt-server:1.1.x-SNAPSHOT
  ports:
  - "21883:1883"
  - "28000:8000"

It gives following error

 Creating my-tt-server
    ←[31mERROR←[0m: Container command not found or does not exist.

I am not sure where it went wrong.

Please help me to solve this. Looks like maven plugin is not correctly deploying the image. How to make it deploy correctly?

 <plugin>
            <groupId>com.spotify</groupId>
            <artifactId>docker-maven-plugin</artifactId>
            <version>0.3.3</version>
            <configuration>
                <dockerDirectory>${project.basedir}/src/main/docker</dockerDirectory>

                <imageName>localhost/my-tt-server</imageName>
                <imageTags>
                    <imageTag>${project.version}</imageTag>
                </imageTags>
                <forceTags>true</forceTags>


            </configuration>
        </plugin>
1

There are 1 answers

9
VonC On BEST ANSWER

if I run 'docker ps -a', it should have displayed this new image. But I am not seeing any image related to this. Hence I am not able to start/run the new image.

No: docker ps -a list the containers, not the images.
Do a docker images to see the list of images, and launch a container with docker run <anImage>.

If your image is built locally, the image directive of docker-compose should be:

image: localhost/my-tt-server:1.1.x-SNAPSHOT

Make sure there is no extra space at the end of that line.

Regarding the error message "Container command not found or does not exist", see issue 20789:

Turns out my issue was the volumes section was not mounting properly because on the windows version only the C:\Users directory gets mounted

or

Turns out that those shell scripts use bash -- of course! Simply change to sh, as bash is not present, resulting in the above error