user11531686
user11531686

Reputation:

How can I get the output of the echo command?

I have a Dockerfile with a RUN instruction like this:

RUN echo "$PWD"

When generating the Docker image I only get this in console:

 Step 6/17 : RUN echo "$PWD" 
 ---> Using cache
 ---> 0e27924953b9

How can I get the output of the echo command in my console?

Upvotes: 3

Views: 717

Answers (1)

spender
spender

Reputation: 120518

Each line in the dockerfile creates a new layer in the resulting filesystem. Unless a modification is made to your dockerfile that hasn't previously been encountered, Docker optimizes the build by reusing existing layers that have previously been built. You can see these intermediate images with the command docker images --all.

This means that Docker only needs to build from the 1st changed line in the dockerfile onwards, saving much time with repeated builds on a well-crafted dockerfile. You've already built this layer in a previous build, so it's being skipped and taken from cache.

docker build --no-cache .

should prevent the build process from using cached layers.

Change the final path parameter above to suit your environment.

Upvotes: 1

Related Questions