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

build --push pushes wrong image name #612

Open
hojerst opened this issue Aug 7, 2023 · 7 comments
Open

build --push pushes wrong image name #612

hojerst opened this issue Aug 7, 2023 · 7 comments
Assignees
Labels
bug Something isn't working

Comments

@hojerst
Copy link

hojerst commented Aug 7, 2023

When doing a devcontainer build --workspace-folder . --image-name my/image:tag --push the wrong image (e.g. vsc-devcontainer-839d9d58687bee078581a54501bbf0ec1d94e4e7a1e7d74dd0f0f02c09f29e0c-features) is pushed instead. The name used seems to be the same as if you do not specify a --image-name at all.

The only workaround is to build the image without --push and push it "manually" after the invocation of devcontainer build. However this can't be used to build and push a multiarch image in buildx, as this needs to be pushed directly out of buildx.

@max06
Copy link

max06 commented Aug 7, 2023

After checking the code, it looks like the CLI doesn't pass all desired image names to the docker buildx-command using repeating -t-flags. Instead it builds the image with the generated name while passing --push to docker, and adding additional tags after the build finished.

Shouldn't be too complicated to fix that behaviour.

@linkinghack
Copy link

Is anyone engaged in this?

@chrmarti chrmarti self-assigned this Sep 5, 2023
@chrmarti chrmarti added the bug Something isn't working label Sep 5, 2023
@max06
Copy link

max06 commented May 13, 2024

@chrmarti @samruddhikhandale hello, good morning.

I've just tried to build a multi-platform image (requiring --push), now being held up by this issue again.

Can someone please have a look at this?


Edit: Some output for visualization

 > exporting to image:
------
ERROR: failed to solve: failed to push vsc-devcontainer-f7736b220b01cfe08693a9270f266d0897087cec814bff6dd8b7017b8ea6c45c-features: push access denied, repository does not exist or may require authorization: server message: insufficient_scope: authorization failed
[2024-05-13T09:24:34.706Z] Exit code 1
{
  "outcome":"error",
  "message":
    "Command failed: 
    docker buildx build 
      --platform linux/amd64,linux/arm64 
      --push 
      --build-context dev_containers_feature_content_source=/tmp/devcontainercli-root/container-features/0.60.0-1715592157021 
      --build-arg _DEV_CONTAINERS_BASE_IMAGE=mcr.microsoft.com/devcontainers/typescript-node:1-20-bookworm 
      --build-arg _DEV_CONTAINERS_IMAGE_USER=root 
      --build-arg _DEV_CONTAINERS_FEATURE_CONTENT_SOURCE=dev_container_feature_content_temp 
      --target dev_containers_target_stage 
      -t vsc-devcontainer-f7736b220b01cfe08693a9270f266d0897087cec814bff6dd8b7017b8ea6c45c-features 
      -t some-internal-gitlab/project/devcontainer:flo-latest 
      -t some-internal-gitlab/project/devcontainer:ad17e4db 
      -f /tmp/devcontainercli-root/container-features/0.60.0-1715592157021/Dockerfile.extended 
      /tmp/devcontainercli-root/empty-folder",
  "description":"An error occurred building the container."}

@eitsupi
Copy link

eitsupi commented May 13, 2024

FYI, here's a wildlife example.
Please check the difference with your command.

https://github.com/rocker-org/devcontainer-images/actions/runs/8848242588/job/24297700205#step:7:22

devcontainer build \
--workspace-folder work/r-ver/4.3 \
--platform linux/amd64,linux/arm64 \
--cache-from ghcr.io/rocker-org/devcontainer/r-ver:4.3 \
--image-name ghcr.io/rocker-org/devcontainer/r-ver:4.3 \
--push true

Converted to...

docker buildx build --platform linux/amd64,linux/arm64 --push --build-arg BUILDKIT_INLINE_CACHE=1 -f /tmp/devcontainercli-runner/container-features/0.59.1-1714134566730/Dockerfile-with-features -t ghcr.io/rocker-org/devcontainer/r-ver:4.3 --target dev_containers_target_stage --cache-from ghcr.io/rocker-org/devcontainer/r-ver:4.3 --build-arg VARIANT=4.3 --build-arg BASE_IMAGE=docker.io/rocker/r-ver --build-context dev_containers_feature_content_source=/tmp/devcontainercli-runner/container-features/0.59.1-1714134566730 --build-arg _DEV_CONTAINERS_BASE_IMAGE=dev_container_auto_added_stage_label --build-arg _DEV_CONTAINERS_IMAGE_USER=root --build-arg _DEV_CONTAINERS_FEATURE_CONTENT_SOURCE=dev_container_feature_content_temp /home/runner/work/devcontainer-images/devcontainer-images/work/r-ver/4.3

@max06
Copy link

max06 commented May 13, 2024

@eitsupi that leaves me a little bit clueless now 😲

I basically copied that command: npx @devcontainers/[email protected] build --workspace-folder . --platform "linux/amd64,linux/arm64" --image-name ghcr.io/rocker-org/devcontainer/r-ver:4.3 --cache-from ghcr.io/rocker-org/devcontainer/r-ver:4.3 --push true (with their image names, yep) and it still tries to create an additional tag. No trace of that tag in the linked action though.

The only diff I see at the moment: We're not building from a Dockerfile.

For ref:

// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/typescript-node
{
	"name": "Dev",
	// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
	"image": "mcr.microsoft.com/devcontainers/typescript-node:1-20-bookworm",
	"features": {
		"ghcr.io/devcontainers/features/kubectl-helm-minikube:1": {},
		"ghcr.io/prulloac/devcontainer-features/bun:1": {
			"version": "1.1.8"
		},
		"ghcr.io/rio/features/k9s": {}
	},
	"customizations": {
		"vscode": {
			"extensions": [
				"cpreston321.nuxt-vscode",
				"Vue.volar",
				"redhat.vscode-yaml",
				"GitLab.gitlab-workflow",
				"vitest.explorer",
				"humao.rest-client",
				"dbaeumer.vscode-eslint",
				"esbenp.prettier-vscode",
				"sibiraj-s.vscode-scss-formatter",
				"syler.sass-indented",
				"formulahendry.auto-rename-tag",
				"formulahendry.auto-close-tag",
				"christian-kohler.path-intellisense"
			]
		}
	}
}

@samruddhikhandale
Copy link
Member

samruddhikhandale commented May 13, 2024

Thanks for the ping, we already have #812 open to fix this issue.

// cc @prathameshzarkar9 Can you help address the PR review feedback so that we can merge the PR sooner? thanks!

@samruddhikhandale
Copy link
Member

Closing as completed with #812

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

6 participants