Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Multi-stage docker build support (using --target in build) does not appear to work

Jason Ryan December 21, 2021
docker build --target build_stage_target -t build_name . 

 

Running the above command in my pipelines does not produce the desired results. The --target flag is apparently ignored, and the build runs all stages before and after the specified stage.

 

Is this indeed not supported or could I be doing something wrong?

 

 

1 answer

1 accepted

1 vote
Answer accepted
Maxim Ugryumov March 15, 2023

This is really an issue 😭
@Jason Ryandid you solve the problem?

Jason Ryan March 15, 2023

Sadly I did not :( 

Maxim Ugryumov March 15, 2023

Ok, thanks!

Maxim Ugryumov March 16, 2023

Hi @Jason Ryan 👋

In our team we found the answer. This is not a Bitbucket issue, but the Docker itself. BuildKit fixes this bug in multi-stage builds in the legacy docker build engine.

So, just enable the BuildKit by inserting the line

- export DOCKER_BUILDKIT=1

before the docker build command and the image will be built with the specified target.

So simple, bro))

Like • Jason Ryan likes this
Jason Ryan March 16, 2023

Fascinating. Thank you for sharing!

Like • Maxim Ugryumov likes this

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events