question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Bug: Docker Multistage Build labeled stage is not detected

See original GitHub issue

Description

Mutlistage Docker Build is failing if named stage is used as a base later:

Info

  • docker-maven-plugin version: 0.34.1
  • maven verison: 3.6.3

Example Dockerfile:

FROM centos AS first

RUN ls -la /

FROM centos as second

RUN ls -la /

# this fails
FROM second

RUN ls -la /

Error:

Failed to execute goal io.fabric8:docker-maven-plugin:0.34.1:build (build-docker) on project xxx-my-project-xxx Unable to pull 'second:latest' : {"message":"pull access denied for second, repository does not exist or may require 'docker login': denied: requested access to the resource is denied"} (Not Found: 404)

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6

github_iconTop GitHub Comments

2reactions
davoustpcommented, Jun 7, 2021

Hi, I agree with this report: the plugin fails because it attempts to pull any FROM image regardless of it being a named image (using FROM ... AS <name>) declared upstream in a multi-stage build. This is actually a regression because it was previously working with version 0.28.0.

A simple project exhibiting the issue is attached to ease reproducing the issue: maven-docker-plugin-fails-with-named-build-stages.tar.gz

Trying to narrow the problem down shows that building with plugin version 0.28.0 passes with flying color when it fails quick & hard with plugin version 0.29.0.

Scanning through the 0.29.0 changelog hints that pull request #1057 is probably the culprit: instead of attempting to pull the first base image only, it attempts to do so with each and every base image (declared with FROM) without checking that the image may be a reference to an already declared and named build stage if it does not declare an alias on itself (found after investigation).

1reaction
davoustpcommented, Jun 7, 2021

Forking now and checking what can be done.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Issue with Docker multi-stage builds - Stack Overflow
I have an issue with a multi-stage build where the binary that is being built in stage one is properly copied to stage...
Read more >
A Guide to Docker Multi-Stage Builds | by Bhargav Bachina
In this article, we will see how we can build images efficiently with Docker multi-stage builds and also we will explore what are...
Read more >
Copying files in multistage docker pipeline fails | Bitbucket Cloud
I get the following error when trying to copy files from a previous build stage. #!generic Step 7/18 : COPY --from=uikit /app/binders-ui-kit.tgz /app...
Read more >
Multi-stage builds - Docker Documentation
The following command assumes you are using the previous Dockerfile but stops at the stage named builder : $ docker build --target builder...
Read more >
Faster Multi-Platform Builds: Dockerfile Cross-Compilation ...
The most common pattern to use in multi-stage builds is to define a build stage(s) where we prepare our build artifacts and a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found