podman icon indicating copy to clipboard operation
podman copied to clipboard

Issues with VSCode Dev Containers Compatibility

Open jakecorrenti opened this issue 2 years ago • 34 comments

Issue Description

I have been trying to document how to set up Visual Studio Code and Dev Containers to use Podman instead of Docker. However, there are some issues that I have run into that are more difficult for me to figure out.

A basic setup for the Dev Containers seems to work fine for both Mac and Linux. However, veering away from the bare-bones examples proves to be unsuccessful.

Steps to reproduce the issue

Steps to reproduce the issue

  1. Install VS Code
  2. Install Dev Containers and Docker extensions
  3. Configure Dev Containers extension to point to the podman and podman-compose paths
  4. Configure Docker extension to point to the podman binary and add the DOCKER_HOST environment variable to point to the podman socket
  5. Open the folder that you want to create the Dev Container in
  6. Use the command palette in Visual Studio Code and type "Dev Containers: Add Dev Configuration Files..."
  7. Select the Debian Image
  8. Select to additionally install the android-sdk
  9. make the following modifications to the devcontainer.json file:
	"workspaceMount": "source=${localWorkspaceFolder},target=/workspace,type=bind,Z",
	"workspaceFolder": "/workspace",

	"runArgs": ["--userns=keep-id"],
	"containerUser": "vscode",

The Resulting devcontainer.json file:

{
	"name": "Debian",
	// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
	"image": "mcr.microsoft.com/devcontainers/base:bullseye",
	"features": {
		"ghcr.io/dhoeric/features/act:1": {},
		"ghcr.io/jarrodcolburn/features/android-sdk:0": {}
	},

	"workspaceMount": "source=${localWorkspaceFolder},target=/workspace,type=bind,Z",
	"workspaceFolder": "/workspace",

	"runArgs": ["--userns=keep-id"],
	"containerUser": "vscode"

	// Features to add to the dev container. More info: https://containers.dev/features.
	// "features": {},

	// Use 'forwardPorts' to make a list of ports inside the container available locally.
	// "forwardPorts": [],

	// Configure tool-specific properties.
	// "customizations": {},

	// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
	// "remoteUser": "root"
}

  1. Use the command palette and type "Dev Containers: Rebuild and Reopen in Container"

Describe the results you received

The container will fail to start with the following error in the logs:

...
[2023-05-25T16:32:30.528Z] Start: Run: /usr/bin/podman buildx build --load --build-context dev_containers_feature_content_source=/tmp/devcontainercli-jakecorrenti/container-features/0.40.0-1685032349431 --build-arg _DEV_CONTAINERS_BASE_IMAGE=mcr.microsoft.com/devcontainers/base:bullseye --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-random-devcontainer-testing-again-eb0f9bee21c08b26e8bd06d0d60b057f58f608c76050732d61ed128bbebe2056-features -f /tmp/devcontainercli-jakecorrenti/container-features/0.40.0-1685032349431/Dockerfile.extended /home/jakecorrenti/.config/Code/User/globalStorage/ms-vscode-remote.remote-containers/data/empty-folder
[2023-05-25T16:32:30.555Z] [1/2] STEP 1/4: FROM mcr.microsoft.com/devcontainers/base:bullseye AS dev_containers_feature_content_normalize
[2023-05-25T16:32:30.567Z] [1/2] STEP 2/4: USER root
[2023-05-25T16:32:30.573Z] --> Using cache b401575ef0223ad8c5318696d1f5d9e10fa57ab8bee15a9f157e53b016d675a4
--> b401575ef022
[2023-05-25T16:32:30.577Z] [1/2] STEP 3/4: COPY --from=dev_containers_feature_content_source devcontainer-features.builtin.env /tmp/build-features/
[2023-05-25T16:32:30.687Z] --> Using cache 50d3d9337e869aa605012825fbec75d660e8d8415b53ca1812ea769c5d1f70d1
--> 50d3d9337e86
[2023-05-25T16:32:30.691Z] [1/2] STEP 4/4: RUN chmod -R 0755 /tmp/build-features/
[2023-05-25T16:32:30.695Z] --> Using cache f67bafdb3d3e5bb2f06b7bf2d43e27d4c2a5c86ab1454413110db250b45e5499
--> f67bafdb3d3e
[2023-05-25T16:32:30.700Z] [2/2] STEP 1/13: FROM mcr.microsoft.com/devcontainers/base:bullseye AS dev_containers_target_stage
[2023-05-25T16:32:30.707Z] [2/2] STEP 2/13: USER root
[2023-05-25T16:32:30.711Z] --> Using cache b401575ef0223ad8c5318696d1f5d9e10fa57ab8bee15a9f157e53b016d675a4
--> b401575ef022
[2023-05-25T16:32:30.715Z] [2/2] STEP 3/13: RUN mkdir -p /tmp/dev-container-features
[2023-05-25T16:32:30.719Z] --> Using cache 9d5d54c787eb6a3b5714e203f1300acc19c5033a887542a5b408a0aedf6bedd9
--> 9d5d54c787eb
[2023-05-25T16:32:30.723Z] [2/2] STEP 4/13: COPY --from=dev_containers_feature_content_normalize /tmp/build-features/ /tmp/dev-container-features
[2023-05-25T16:32:30.830Z] --> Using cache d66edbaf27fcab262bf6e887012a7fd5e7305a4cf3e69ef9c2c3747e564b3699
--> d66edbaf27fc
[2023-05-25T16:32:30.834Z] [2/2] STEP 5/13: RUN echo "_CONTAINER_USER_HOME=$(getent passwd vscode | cut -d: -f6)" >> /tmp/dev-container-features/devcontainer-features.builtin.env && echo "_REMOTE_USER_HOME=$(getent passwd vscode | cut -d: -f6)" >> /tmp/dev-container-features/devcontainer-features.builtin.env
[2023-05-25T16:32:30.838Z] --> Using cache 8d101aac6795c9a1ef2ef9ef3817ab8ae43c0031a5b230adbfea4aa7123619fb
--> 8d101aac6795
[2023-05-25T16:32:30.843Z] [2/2] STEP 6/13: RUN --mount=type=bind,from=dev_containers_feature_content_source,source=act_1,target=/tmp/build-features-src/act_1     cp -ar /tmp/build-features-src/act_1 /tmp/dev-container-features  && chmod -R 0755 /tmp/dev-container-features/act_1  && cd /tmp/dev-container-features/act_1  && chmod +x ./devcontainer-features-install.sh  && ./devcontainer-features-install.sh  && rm -rf /tmp/dev-container-features/act_1
[2023-05-25T16:32:30.984Z] cp: cannot access '/tmp/build-features-src/act_1': Permission denied
[2023-05-25T16:32:31.073Z] Error: building at STEP "RUN --mount=type=bind,from=dev_containers_feature_content_source,source=act_1,target=/tmp/build-features-src/act_1 cp -ar /tmp/build-features-src/act_1 /tmp/dev-container-features  && chmod -R 0755 /tmp/dev-container-features/act_1  && cd /tmp/dev-container-features/act_1  && chmod +x ./devcontainer-features-install.sh  && ./devcontainer-features-install.sh  && rm -rf /tmp/dev-container-features/act_1": while running runtime: exit status 1
[2023-05-25T16:32:31.076Z] Stop (548 ms): Run: /usr/bin/podman buildx build --load --build-context dev_containers_feature_content_source=/tmp/devcontainercli-jakecorrenti/container-features/0.40.0-1685032349431 --build-arg _DEV_CONTAINERS_BASE_IMAGE=mcr.microsoft.com/devcontainers/base:bullseye --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-random-devcontainer-testing-again-eb0f9bee21c08b26e8bd06d0d60b057f58f608c76050732d61ed128bbebe2056-features -f /tmp/devcontainercli-jakecorrenti/container-features/0.40.0-1685032349431/Dockerfile.extended /home/jakecorrenti/.config/Code/User/globalStorage/ms-vscode-remote.remote-containers/data/empty-folder
[2023-05-25T16:32:31.076Z] Error: Command failed: /usr/bin/podman buildx build --load --build-context dev_containers_feature_content_source=/tmp/devcontainercli-jakecorrenti/container-features/0.40.0-1685032349431 --build-arg _DEV_CONTAINERS_BASE_IMAGE=mcr.microsoft.com/devcontainers/base:bullseye --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-random-devcontainer-testing-again-eb0f9bee21c08b26e8bd06d0d60b057f58f608c76050732d61ed128bbebe2056-features -f /tmp/devcontainercli-jakecorrenti/container-features/0.40.0-1685032349431/Dockerfile.extended /home/jakecorrenti/.config/Code/User/globalStorage/ms-vscode-remote.remote-containers/data/empty-folder
[2023-05-25T16:32:31.077Z]     at Tse (/home/jakecorrenti/.vscode/extensions/ms-vscode-remote.remote-containers-0.292.0/dist/spec-node/devContainersSpecCLI.js:1946:3264)
[2023-05-25T16:32:31.077Z]     at rO (/home/jakecorrenti/.vscode/extensions/ms-vscode-remote.remote-containers-0.292.0/dist/spec-node/devContainersSpecCLI.js:1946:3200)
[2023-05-25T16:32:31.077Z]     at process.processTicksAndRejections (node:internal/process/task_queues:96:5)
[2023-05-25T16:32:31.077Z]     at async Xse (/home/jakecorrenti/.vscode/extensions/ms-vscode-remote.remote-containers-0.292.0/dist/spec-node/devContainersSpecCLI.js:1961:2626)
[2023-05-25T16:32:31.077Z]     at async vh (/home/jakecorrenti/.vscode/extensions/ms-vscode-remote.remote-containers-0.292.0/dist/spec-node/devContainersSpecCLI.js:1961:3741)
[2023-05-25T16:32:31.077Z]     at async gae (/home/jakecorrenti/.vscode/extensions/ms-vscode-remote.remote-containers-0.292.0/dist/spec-node/devContainersSpecCLI.js:2092:10213)
[2023-05-25T16:32:31.077Z]     at async mae (/home/jakecorrenti/.vscode/extensions/ms-vscode-remote.remote-containers-0.292.0/dist/spec-node/devContainersSpecCLI.js:2092:9954)
[2023-05-25T16:32:31.081Z] Stop (2020 ms): Run: /usr/share/code/code --ms-enable-electron-run-as-node /home/jakecorrenti/.vscode/extensions/ms-vscode-remote.remote-containers-0.292.0/dist/spec-node/devContainersSpecCLI.js up --user-data-folder /home/jakecorrenti/.config/Code/User/globalStorage/ms-vscode-remote.remote-containers/data --docker-path /usr/bin/podman --docker-compose-path podman-compose --container-session-data-folder /tmp/devcontainers-d8bac0b3-49ab-42f9-b4c4-fba0cef89aaa1685032348011 --workspace-folder /home/jakecorrenti/random-devcontainer-testing-again --workspace-mount-consistency cached --id-label devcontainer.local_folder=/home/jakecorrenti/random-devcontainer-testing-again --id-label devcontainer.config_file=/home/jakecorrenti/random-devcontainer-testing-again/.devcontainer/devcontainer.json --log-level debug --log-format json --config /home/jakecorrenti/random-devcontainer-testing-again/.devcontainer/devcontainer.json --default-user-env-probe loginInteractiveShell --remove-existing-container --mount type=volume,source=vscode,target=/vscode,external=true --skip-post-create --update-remote-user-uid-default on --mount-workspace-git-root true
[2023-05-25T16:32:31.082Z] Exit code 1
[2023-05-25T16:32:31.086Z] Command failed: /usr/share/code/code --ms-enable-electron-run-as-node /home/jakecorrenti/.vscode/extensions/ms-vscode-remote.remote-containers-0.292.0/dist/spec-node/devContainersSpecCLI.js up --user-data-folder /home/jakecorrenti/.config/Code/User/globalStorage/ms-vscode-remote.remote-containers/data --docker-path /usr/bin/podman --docker-compose-path podman-compose --container-session-data-folder /tmp/devcontainers-d8bac0b3-49ab-42f9-b4c4-fba0cef89aaa1685032348011 --workspace-folder /home/jakecorrenti/random-devcontainer-testing-again --workspace-mount-consistency cached --id-label devcontainer.local_folder=/home/jakecorrenti/random-devcontainer-testing-again --id-label devcontainer.config_file=/home/jakecorrenti/random-devcontainer-testing-again/.devcontainer/devcontainer.json --log-level debug --log-format json --config /home/jakecorrenti/random-devcontainer-testing-again/.devcontainer/devcontainer.json --default-user-env-probe loginInteractiveShell --remove-existing-container --mount type=volume,source=vscode,target=/vscode,external=true --skip-post-create --update-remote-user-uid-default on --mount-workspace-git-root true
[2023-05-25T16:32:31.087Z] Exit code 1

Describe the results you expected

I expected the container to successfully start with no errors

podman info output

host:
  arch: amd64
  buildahVersion: 1.31.0-dev
  cgroupControllers:
  - cpu
  - io
  - memory
  - pids
  cgroupManager: cgroupfs
  cgroupVersion: v2
  conmon:
    package: Unknown
    path: /usr/local/libexec/podman/conmon
    version: 'conmon version 2.1.7, commit: d5564f8c3693d2e54b45555fd8f3b1596b0e6d77'
  cpuUtilization:
    idlePercent: 80.47
    systemPercent: 4.12
    userPercent: 15.41
  cpus: 8
  databaseBackend: boltdb
  distribution:
    distribution: fedora
    variant: workstation
    version: "38"
  eventLogger: file
  hostname: fedora
  idMappings:
    gidmap:
    - container_id: 0
      host_id: 1000
      size: 1
    - container_id: 1
      host_id: 524288
      size: 65536
    uidmap:
    - container_id: 0
      host_id: 1000
      size: 1
    - container_id: 1
      host_id: 524288
      size: 65536
  kernel: 6.2.15-300.fc38.x86_64
  linkmode: dynamic
  logDriver: k8s-file
  memFree: 17991634944
  memTotal: 33386004480
  networkBackend: netavark
  ociRuntime:
    name: crun
    package: crun-1.8.5-1.fc38.x86_64
    path: /usr/bin/crun
    version: |-
      crun version 1.8.5
      commit: b6f80f766c9a89eb7b1440c0a70ab287434b17ed
      rundir: /run/user/1000/crun
      spec: 1.0.0
      +SYSTEMD +SELINUX +APPARMOR +CAP +SECCOMP +EBPF +CRIU +LIBKRUN +WASM:wasmedge +YAJL
  os: linux
  remoteSocket:
    exists: true
    path: /run/user/1000/podman/podman.sock
  security:
    apparmorEnabled: false
    capabilities: CAP_CHOWN,CAP_DAC_OVERRIDE,CAP_FOWNER,CAP_FSETID,CAP_KILL,CAP_NET_BIND_SERVICE,CAP_SETFCAP,CAP_SETGID,CAP_SETPCAP,CAP_SETUID,CAP_SYS_CHROOT
    rootless: true
    seccompEnabled: true
    seccompProfilePath: /usr/share/containers/seccomp.json
    selinuxEnabled: true
  serviceIsRemote: false
  slirp4netns:
    executable: /usr/bin/slirp4netns
    package: slirp4netns-1.2.0-12.fc38.x86_64
    version: |-
      slirp4netns version 1.2.0
      commit: 656041d45cfca7a4176f6b7eed9e4fe6c11e8383
      libslirp: 4.7.0
      SLIRP_CONFIG_VERSION_MAX: 4
      libseccomp: 2.5.3
  swapFree: 8589930496
  swapTotal: 8589930496
  uptime: 5h 24m 40.00s (Approximately 0.21 days)
plugins:
  authorization: null
  log:
  - k8s-file
  - none
  - passthrough
  network:
  - bridge
  - macvlan
  - ipvlan
  volume:
  - local
registries:
  search:
  - registry.fedoraproject.org
  - registry.access.redhat.com
  - docker.io
  - quay.io
store:
  configFile: /home/jakecorrenti/.config/containers/storage.conf
  containerStore:
    number: 0
    paused: 0
    running: 0
    stopped: 0
  graphDriverName: overlay
  graphOptions: {}
  graphRoot: /home/jakecorrenti/.local/share/containers/storage
  graphRootAllocated: 254356226048
  graphRootUsed: 16890331136
  graphStatus:
    Backing Filesystem: btrfs
    Native Overlay Diff: "true"
    Supports d_type: "true"
    Using metacopy: "false"
  imageCopyTmpDir: /var/tmp
  imageStore:
    number: 162
  runRoot: /run/user/1000/containers
  transientStore: false
  volumePath: /home/jakecorrenti/.local/share/containers/storage/volumes
version:
  APIVersion: 4.6.0-dev
  Built: 1684776405
  BuiltTime: Mon May 22 13:26:45 2023
  GitCommit: b15510694b81929dbc107d354fdb0a83d0bfaa2a
  GoVersion: go1.20.4
  Os: linux
  OsArch: linux/amd64
  Version: 4.6.0-dev

Podman in a container

No

Privileged Or Rootless

Rootless

Upstream Latest Release

Yes

Additional environment details

$ podman-compose --version
podman-compose version: 1.0.6
['podman', '--version', '']
using podman version: 4.6.0-dev
podman-compose version 1.0.6
podman --version 
podman version 4.6.0-dev
exit code: 0

Additional information

Additional incompatibilities:

  • Follow the initial instructions above up until step 7. Instead, select the image "Anaconda (Python 3) & PostgreSQL"
  • Select "OK" to install no additional software
  • make the following modification to the devcontainer.json file:
"containerUser": "vscode",

// The other configuration items that were added above are not supported for this image's configuration
  • the resulting devcontainer.json file:
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/anaconda-postgres
{
	"name": "Anaconda (Python 3) & PostgreSQL",
	"dockerComposeFile": "docker-compose.yml",
	"service": "app",
	"workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}",
	"containerUser": "vscode"
	
	// Features to add to the dev container. More info: https://containers.dev/features.
	// "features": {},

	// Use 'forwardPorts' to make a list of ports inside the container available locally.
	// "forwardPorts": [5432],

	// Use 'postCreateCommand' to run commands after the container is created.
	// "postCreateCommand": "python --version",

	// Configure tool-specific properties.
	// "customizations": {},

	// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
	// "remoteUser": "root"
}

  • When attempting to Rebuild and Reopen this in a Container, nothing happens.
  • I also expected this to result in the container/server starting and loading correctly

This issue refers to the current open PR: #18679

jakecorrenti avatar May 25 '23 18:05 jakecorrenti