Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: Docker Multistage Build labeled stage is not detected #1443

Closed
Xyaren opened this issue Mar 19, 2021 · 6 comments · Fixed by #1478
Closed

Bug: Docker Multistage Build labeled stage is not detected #1443

Xyaren opened this issue Mar 19, 2021 · 6 comments · Fixed by #1478
Labels

Comments

@Xyaren
Copy link
Contributor

Xyaren commented Mar 19, 2021

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)

@davoustp
Copy link

davoustp commented 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).

@rohanKanojia
Copy link
Member

@davoustp : Thanks for the investigation, Would it be possible to submit a fix for this issue?

@davoustp
Copy link

davoustp commented Jun 7, 2021

Forking now and checking what can be done.

@rohanKanojia
Copy link
Member

@davoustp : Thanks a lot!

@davoustp
Copy link

davoustp commented Jun 7, 2021

Done. Sonar analysis fails as it looks it required more permission than I have.

@rohanKanojia
Copy link
Member

Don't worry about it, our sonar job is failing right now due to removal of sonarcube token. I'll probably remove it or add new token

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants