Skip to content

Docker Build Command Output Not Showing: Fixes and Solutions

When building Docker images, you may notice that command output from RUN instructions isn't displayed, making debugging difficult. This article explains why this happens and provides several solutions to show the command output during builds.

Problem: No Output from RUN Commands

By default, Docker BuildKit (the modern build system) shows minimal output:

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

Instead of seeing the expected "hello world" and psql version output, you see:

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

Root Cause: BuildKit's Default Behavior

Docker's BuildKit engine (default since Docker 18.09) uses a condensed output format that doesn't show command output by default. This differs from the older Docker build engine which was more verbose.

The most straightforward solution is to use the --progress=plain flag:

bash
docker build --progress=plain .

For Docker Compose:

bash
docker compose build --progress=plain <container_name>

This shows the full output of all commands during the build process.

Solution 2: Set Environment Variable for Permanent Change

To avoid specifying the flag every time, set the environment variable:

bash
export BUILDKIT_PROGRESS=plain

Now all subsequent docker build commands will show full command output.

Solution 3: Disable Caching When Debugging

If your commands have been cached from previous builds, use --no-cache to force re-execution:

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

WARNING

Using --no-cache significantly increases build time as it rebuilds all layers from scratch.

Solution 4: Revert to Legacy Build Engine

If you prefer the old behavior, you can disable BuildKit entirely:

bash
DOCKER_BUILDKIT=0 docker build .

Or set it permanently:

bash
export DOCKER_BUILDKIT=0

INFO

The legacy build engine may be deprecated in future Docker versions, so this is not a long-term solution.

Advanced: Force Command Execution with Cache Busting

If you need to see output from a specific command without rebuilding everything, you can add a cache-busting technique:

dockerfile
RUN your_command && echo "cache-bust-$(date +%s)"

Change the cache-busting string each time to force Docker to rerun the command.

Common Pitfall: Windows Line Endings

If you see errors like /bin/sh: 1: /install.sh: not found, you might have Windows line endings (CRLF) in your scripts. Convert them to Unix line endings (LF) using your editor.

TIP

In VS Code, click the "CRLF" button in the bottom right corner and select "LF" to convert line endings.

Summary

MethodCommandUse Case
Plain progressdocker build --progress=plain .Temporary debugging
Environment variableexport BUILDKIT_PROGRESS=plainPermanent solution
No cachedocker build --progress=plain --no-cache .Force all commands to rerun
Disable BuildKitDOCKER_BUILDKIT=0 docker build .Legacy behavior

The recommended approach for most cases is using --progress=plain when you need to debug builds, or setting BUILDKIT_PROGRESS=plain as an environment variable for consistent verbose output.