Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is docker build not showing any output from commands?

Snippet from my Dockerfile:

FROM node:12.18.0
RUN echo "hello world"
RUN psql --version

When I run docker build . I don't see any output from these two commands even if they are not cached. The documentation says that docker build is verbose by default. Why am I not seeing the output from commands? I used to see them before.

The output while building:

=> [7/18] RUN echo "hello world"                         0.9s

The output I am seeing after building finishes:

=> CACHED [6/18] RUN apt-get install postgresql -y      0.0s
=> [7/18] RUN echo "hello world"                        6.4s
=> [8/18] RUN psql --version                           17.1s

The Dockerfile is created from node:12.18.0 which is based on Debian 9.

Docker version 19.03.13, build 4484c46d9d.

like image 346
Noname Avatar asked Oct 04 '22 03:10

Noname


People also ask

Where is the output of docker build?

They get stored as a series of layers in your Docker root directory. On Linux, it's /var/lib/docker .

How can I see docker output?

docker logs <container id> will show you all the output of the container run. If you're running it on ECS, you'll probably need to set DOCKER_HOST=tcp://ip:port for the host that ran the container. My container is already stopped. Using the cmd line doing, docker run -d image, it returns me the container id.

What is the output of docker Run command?

The output you receive will be similar to the one you see in the image above. The container will run the process and then stop. No other output will display inside the terminal session. Note: Running Docker privileged containers is also one of the most commonly used run commands.


1 Answers

The output you are showing is from buildkit, which is a replacement for the classic build engine that docker ships with. You can adjust output from this with the --progress option:

  --progress string         Set type of progress output (auto, plain, tty). Use plain to show container output
                            (default "auto")

Adding --progress=plain will show the output of the run commands that were not loaded from the cache. This can also be done by setting the BUILDKIT_PROGRESS variable:

export BUILDKIT_PROGRESS=plain

If you are debugging a build, and the steps have already been cached, add --no-cache to your build to rerun the steps and redisplay the output:

docker build --progress=plain --no-cache ...

If you don't want to use buildkit, you can revert to the older build engine by exporting DOCKER_BUILDKIT=0 in your shell, e.g.:

DOCKER_BUILDKIT=0 docker build ...

or

export DOCKER_BUILDKIT=0
docker build ...
like image 339
BMitch Avatar answered Oct 13 '22 22:10

BMitch