Docker 虽然我使用 maven docker 插件构建,但图像未列出

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

我使用以下命令构建了 docker 图像。 (使用 com.spotify:docker-maven-plugin:0.3.3 maven 插件)。我在 Windows.

中使用 Docker 工具箱
mvn clean package docker:build

它通过以下描述给出了 SUCCESS。

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] ------------------------------------------------------------------------

在这之后,如果我运行 'docker ps -a',它应该会显示这个新图像。但我没有看到与此相关的任何图像。因此我无法 start/run 新图像。

我无法 运行 'docker-compose up my-tt-server' 在 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"

它给出以下错误

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

我不确定哪里错了。

请帮我解决这个问题。 看起来 Maven 插件没有正确部署图像。如何使其正确部署?

 <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>

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.

否:docker ps -a 列出容器,而不是图像。
执行 docker images 查看图像列表,并使用 docker run <anImage>.

启动容器

如果您的镜像是本地构建的,image directive of docker-compose 应该是:

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

确保该行末尾没有多余的 space。

关于错误信息“Container command not found or does not exist”,参见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

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