Image is not built completely

I am currently trying to build an image using a Dockerfile. At the end of the Dockerfile I have implemented echo for testing purposes.

FROM nginx:1.21.6-alpine

RUN echo 'hello world'

It seems that nothing is printed on the console. Also, I don’t get a message that the image was built successfully.

docker build .
[+] Building 2.9s (6/6) FINISHED                                                                                                                                                                                          
 => [internal] load build definition from Dockerfile                                                                                                                                                                
 => => transferring dockerfile: 90B                                                                                                                                                                                 
 => [internal] load .dockerignore                                                                                                                                                                                   
 => => transferring context: 57B                                                                                                                                                                                    
 => [internal] load metadata for docker.io/library/nginx:1.21.6-alpine                                                                                                                                              
 => [1/2] FROM docker.io/library/nginx:1.21.6-alpine@sha256:a74534e76ee1121d418fa7394ca930eb67440deda413848bc67c68138535b989                                                                                        
[...]                                                                                                                       
 => [2/2] RUN echo 'hello world'                                                                                                                                                                                     
 => exporting to image                                                                                                                                                                                               
 => => exporting layers                                                                                                                                                                                              
 => => writing image sha256:efbbc04c40c43edb7e31a24df67807fcb469f1ec46ba0d964b12e040ee39e656

Shouldn’t a “hello world” be displayed in the console? When I try to start the image, I also get an error message:

Error invoking remote method ‘docker-run-container’: Error: (HTTP code 400) unexpected - invalid reference format

The image also has no name and no tag:

Bildschirmfoto 2022-05-18 um 14.30.53

Is that correct? What am I doing wrong?

Hi

it could be that docker is using a layer from cache, and will therefore not display the output of your echo command.

Regarding the name, the reason it dosnt have any, is because you didnt specify any:

docker build -t myimage:latest .

Based on the output I think it is because you built your image using Buildkit, so it shows you the output only in build time and the output disappears so you can see the steps without a very long output. If you need to see the output of echo, you can disable buildkit:

DOCKER_BUILDKIT=0 docker build ...

True, but in that case it should show something like “CACHE” in the output, shouldn’t it?