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

Unable to prebuild devcontainer image (error command docker tag) #271

Open
Defman opened this issue Jan 18, 2024 · 7 comments
Open

Unable to prebuild devcontainer image (error command docker tag) #271

Defman opened this issue Jan 18, 2024 · 7 comments
Assignees
Labels
bug Something isn't working info-needed Issue requires more information from poster

Comments

@Defman
Copy link

Defman commented Jan 18, 2024

Error

Error: Dev container build failed: Command failed: docker tag example_devcontainer_app ghcr.io/example/example-devcontainer:latest (exit code: undefined)
An error occurred building the container. Error: Command failed: docker tag example_devcontainer_app ghcr.io/example/example-devcontainer:latest

The error only occurs when trying to push the image, the simplest setup without cacheFrom and push works like a charm.

Setup

.devcontainer/
├── devcontainer.json
├── docker-compose.yaml
└── Dockerfile
  build:
    name: Build
    runs-on: 16cores
    steps:
      - name: Checkout sources
        uses: actions/checkout@v3

      - name: Login to GitHub Container Registry
        uses: docker/login-action@v3
        with:
          registry: ghcr.io
          username: ${{ github.repository_owner }}
          password: ${{ secrets.GITHUB_TOKEN }}

      - name: Pre-build dev container image
        uses: devcontainers/ci@v0.3
        with:
          imageName: ghcr.io/example/example-devcontainer
          cacheFrom: ghcr.io/example/example-devcontainer
          push: always
@onedr0p
Copy link

onedr0p commented Jan 23, 2024

I have the same issue:

Dev container build failed: Command failed: docker tag vsc-flux-cluster-template-4e21694e9925a5c8755fd5fcba59eadc1f9d0c5b2a7d26a4ed5207ad79324fac-features ghcr.io/onedr0p/flux-cluster-template/devcontainer:latest (exit code: undefined)
jobs:
  publish-devcontainer:
    name: Publish devcontainer
    runs-on: ubuntu-latest
    permissions:
      contents: read
      packages: write
    steps:
      - name: Checkout
        uses: actions/checkout@v4

      - name: Set up QEMU
        uses: docker/setup-qemu-action@v3

      - name: Set up Docker Buildx
        uses: docker/setup-buildx-action@v3
        with:
          platforms: linux/amd64 # ,linux/arm64

      - name: Login to GitHub Container Registry
        uses: docker/login-action@v3
        with:
          registry: ghcr.io
          username: ${{ github.actor }}
          password: ${{ secrets.GITHUB_TOKEN }}

      - name: Build and push
        uses: devcontainers/ci@v0.3
        with:
          imageName: ghcr.io/${{ github.repository }}/devcontainer
          cacheFrom: ghcr.io/${{ github.repository }}/devcontainer
          imageTag: latest
          platform: linux/amd64 # ,linux/arm64
          configFile: .devcontainer/devcontainer.build.json
          push: always

@onedr0p
Copy link

onedr0p commented Jan 23, 2024

Maybe a duplicate? #191

chrmarti added a commit to devcontainers/cli that referenced this issue Mar 1, 2024
@chrmarti chrmarti self-assigned this Mar 1, 2024
@chrmarti chrmarti added the bug Something isn't working label Mar 1, 2024
chrmarti added a commit to devcontainers/cli that referenced this issue Mar 1, 2024
@chrmarti
Copy link
Collaborator

chrmarti commented Mar 4, 2024

Fixed in the Dev Containers CLI 0.57.0. The CI action will automatically pick up that version.

@chrmarti chrmarti closed this as completed Mar 4, 2024
@chrmarti chrmarti added this to the March 2024 milestone Mar 4, 2024
@mintuhouse
Copy link

This error still happens for me

About to run devcontainer build --workspace-folder /home/runner/work/rhythms/rhythms --config /home/runner/work/rhythms/rhythms/.devcontainer/mlai/devcontainer.json --image-name ghcr.io/GetRhythms/rhythms/rhythms-mlai-dev-mintuhouse/ruff:latest --cache-from ghcr.io/GetRhythms/rhythms/rhythms-mlai-dev-mintuhouse/ruff:latest --cache-from ghcr.io/GetRhythms/rhythms/rhythms-mlai-dev-main
  [2024-05-07T23:37:31.996Z] @devcontainers/cli 0.60.0. Node.js v18.20.2. linux 6.5.0-1018-azure x64.

Error: Dev container build failed: Command failed: docker tag mlai_mlai ghcr.io/GetRhythms/rhythms/rhythms-mlai-dev-mintuhouse/ruff:latest (exit code: undefined)

devcontainer:
   runs-on: ubuntu-latest
   steps:
     - uses: actions/checkout@v4
     - uses: docker/login-action@v2
       with:
         registry: ghcr.io
         username: ${{ github.repository_owner }}
         password: ${{ secrets.GITHUB_TOKEN }}
     - name: Pre-build dev container image
       uses: devcontainers/ci@v0.3
       env:
         BUILDX_NO_DEFAULT_ATTESTATIONS: true # https://github.com/devcontainers/ci/issues/191#issuecomment-1603857155
       with:
         configFile: .devcontainer/mlai/devcontainer.json
         cacheFrom: ghcr.io/${{ github.repository }}/rhythms-mlai-dev-main
         imageName: ghcr.io/${{ github.repository }}/rhythms-mlai-dev-${{github.ref_name}}
         # imageTag: ${{ env.IMAGE_TAG }}
         # platform: linux/amd64,linux/arm64
         skipContainerUserIdUpdate: true

@chrmarti
Copy link
Collaborator

chrmarti commented May 8, 2024

Looking at the code, this might still occur when you are using a devcontainer.json with an image and no features or with a Docker Compose configuration.

@mintuhouse Could you append your devcontainer.json?

@chrmarti chrmarti reopened this May 8, 2024
@chrmarti chrmarti added the info-needed Issue requires more information from poster label May 8, 2024
@chrmarti chrmarti removed this from the March 2024 milestone May 8, 2024
@mintuhouse
Copy link

We use docker compose

// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/docker-existing-docker-compose
{
  "name": "ML AI (Rhythms)",
  "initializeCommand": "${localWorkspaceFolder}/.devcontainer/hostsetup",
  // Update the 'dockerComposeFile' list if you have more compose files or use different names.
  // The .devcontainer/docker-compose.yml file contains any overrides you need/want to make.
  "dockerComposeFile": [
    "../../mlai/docker-compose.yml",
    "docker-compose.extend.yml"
  ],
  // The 'service' property is the name of the service for the container that VS Code should
  // use. Update this value and .devcontainer/docker-compose.yml to the real service name.
  "service": "mlai",
  // The optional 'workspaceFolder' property is the path VS Code should open by default when
  // connected. This is typically a file mount in .devcontainer/docker-compose.yml
  "workspaceFolder": "/workspaces/rhythms/mlai",
  // Features to add to the dev container. More info: https://containers.dev/features.
  "features": {
    // "azure-cli": "latest",
    "ghcr.io/devcontainers/features/docker-outside-of-docker:1": {
      "moby": true,
      "installDockerBuildx": true,
      "version": "latest",
      "dockerDashComposeVersion": "v2"
    },
    // "ghcr.io/devcontainers-contrib/features/actions-runner:1": {
    // 	"version": "latest",
    // 	"dotnetVersion": "latest"
    // },
    // "ghcr.io/devcontainers/features/github-cli:1": {
    //   "version": "latest"
    // },
    "ghcr.io/devcontainers-contrib/features/apt-get-packages:1": {
      "preserve_apt_list": false,
      "packages": "htop",
      "ppas": ""
    },
    "ghcr.io/devcontainers-contrib/features/zsh-plugins:0": {
      "plugins": "git git-extras git-prompt direnv",
      "omzPlugins": "https://github.com/zsh-users/zsh-autosuggestions"
    },
    // "ghcr.io/devcontainers/features/dotnet:2": {},
    "ghcr.io/devcontainers-contrib/features/localtunnel-npm:1": {}
  },
  // Use 'forwardPorts' to make a list of ports inside the container available locally.
  "forwardPorts": [],
  "otherPortsAttributes": {
    // Prevent auto-forwarding of ports
    "onAutoForward": "ignore"
  },
  // Uncomment the next line if you want start specific services in your Docker Compose config.
  // "runServices": [],
  // Uncomment the next line if you want to keep your containers running after VS Code shuts down.
  // "shutdownAction": "none",
  // Run commands after the container is created.
  "postCreateCommand": "/workspaces/rhythms/mlai/bin/devcontainer-setup",
  // Executes every time the container starts
  // "postStartCommand": "bash -i post-start.sh",
  // Configure tool-specific properties.
  "customizations": {
    // Configure properties specific to VS Code.
    "vscode": {
      "settings": {
        "terminal.integrated.defaultProfile.linux": "zsh",
        "terminal.integrated.profiles.linux": {
          "zsh": {
            "path": "/usr/bin/zsh"
          }
        }
      },
      // Add the IDs of extensions you want installed when the container is created.
      "extensions": [
        "streetsidesoftware.code-spell-checker",
        "bierner.github-markdown-preview",
        "ms-azuretools.vscode-docker",
        "eamodio.gitlens",
        "GitHub.copilot",
        "GitHub.vscode-pull-request-github",
        "esbenp.prettier-vscode",
        "foxundermoon.shell-format",
        "redhat.vscode-yaml",
        "github.vscode-github-actions",
        "Postman.postman-for-vscode",
        "yokawasa.jwt-debugger",
        "ms-python.python",
        "charliermarsh.ruff",
        "njpwerner.autodocstring",
        "tamasfe.even-better-toml",
        "ms-toolsai.jupyter",
        "ms-toolsai.datawrangler",
        "ms-toolsai.vscode-ai",
        "ms-toolsai.vscode-ai-remote",
        "ms-toolsai.vscode-jupyter-powertoys"
      ]
    }
  },
  // Uncomment to connect as an existing user other than the container default. More info: https://aka.ms/dev-containers-non-root.
  // "remoteUser": "devcontainer"
  "remoteEnv": {
    "CI": "${localEnv:CI}",
    "PATH": "${containerEnv:PATH}:/some/other/path"
  }
}

@tlgDJPorv
Copy link

Our github org is in all caps, so using the expression ghcr.io/${{ github.repository }}/devcontainer for imageName is a no go.
Added a small step that lowercased the image name, and presto, now it works.
Just adding the comment here incase anyone else that googles their way to this issue might find it useful and save a couple of hours pulling their hair out :-).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working info-needed Issue requires more information from poster
Projects
None yet
Development

No branches or pull requests

5 participants