`overrideCommand` option does not correctly overwrite entrypoint
Description
Currently, even with overrideCommand set to false, the devcontainer still forces the entrypoint as /bin/sh, which prevents the other init system likesystemd to start as PID 1.
Because of this bug, current devcontainerCLI fails to run systemd in a rootless podman container. Even though podman has official support for running systemd in container.
Here are the offending lines. Note the --entrypoint always stays as /bin/sh, and persists in the actual arguments to run the container.
https://github.com/devcontainers/cli/blob/c1c8b08263c6dca7cd79c97a2d0bc581fcef4f6c/src/spec-node/singleContainer.ts#L385-L415
Test setup
1. Dockerfile
FROM ubuntu:22.04
RUN apt update && apt install -y systemd
RUN systemctl set-default multi-user.target
ENTRYPOINT [ "/lib/systemd/systemd"]
Build and run using podman works:
podman build -t systemd .
podman run -d --name systemd
podman exec -it systemd systemctl
2. devcontainer using the same dockerfile
However, the same Dockerfile cannot be run in devcontainer. Here is the devcotnainer.json
{
"name": "podman with systemd",
"build": {
"context": "..",
"dockerfile": "../Dockerfile"
},
"overrideCommand": false,
}
And here is the full log of the devcontainer:
[2024-05-02T18:23:00.654Z] Dev Containers 0.364.0 over Remote - SSH 0.110.1 in VS Code 1.88.1 (e170252f762678dec6ca2cc69aba1570769a5d39).
[2024-05-02T18:23:00.654Z] Start: Resolving Remote
[2024-05-02T18:23:00.656Z] Host OS: linux 6.5.0-26-generic
[2024-05-02T18:23:00.656Z] Host CWD: /workspace/devcontainer
[2024-05-02T18:23:00.656Z] Start: Run: /bin/sh
[2024-05-02T18:23:00.658Z] Start: Run in host: echo ~
[2024-05-02T18:23:00.700Z] /home/user
[2024-05-02T18:23:00.701Z]
[2024-05-02T18:23:00.701Z] Stop (43 ms): Run in host: echo ~
[2024-05-02T18:23:00.701Z] Start: Run in host: id -un
[2024-05-02T18:23:00.745Z] user
[2024-05-02T18:23:00.745Z]
[2024-05-02T18:23:00.746Z] Stop (45 ms): Run in host: id -un
[2024-05-02T18:23:00.746Z] Start: Run in host: (command -v getent >/dev/null 2>&1 && getent passwd 'user' || grep -E '^user|^[^:]*:[^:]*:user:' /etc/passwd || true)
[2024-05-02T18:23:00.793Z] Stop (47 ms): Run in host: (command -v getent >/dev/null 2>&1 && getent passwd 'user' || grep -E '^user|^[^:]*:[^:]*:user:' /etc/passwd || true)
[2024-05-02T18:23:00.793Z] userEnvProbe: loginInteractiveShell (default)
[2024-05-02T18:23:00.794Z] userEnvProbe: not found in cache
[2024-05-02T18:23:00.794Z] userEnvProbe shell: /bin/bash
[2024-05-02T18:23:00.848Z] userEnvProbe PATHs:
Probe: '/home/user/.local/bin:/home/user/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin'
Container: None
[2024-05-02T18:23:00.853Z] Setting up container for folder or workspace: /workspace/devcontainer
[2024-05-02T18:23:00.853Z] Host authority: ssh-remote+server
[2024-05-02T18:23:00.853Z] Host: unix:///run/user/2033810832/docker.sock
[2024-05-02T18:23:00.857Z] Start: Check Docker is running
[2024-05-02T18:23:00.857Z] Start: Run: podman version
[2024-05-02T18:23:00.904Z] Client: Podman Engine
Version: 4.5.0
API Version: 4.5.0
Go Version: go1.18.1
Built: Wed Dec 31 16:00:00 1969
OS/Arch: linux/amd64
[2024-05-02T18:23:00.905Z] Stop (48 ms): Run: podman version
[2024-05-02T18:23:00.905Z] Stop (48 ms): Check Docker is running
[2024-05-02T18:23:00.905Z] Start: Run: podman volume ls -q
[2024-05-02T18:23:00.980Z] Stop (75 ms): Run: podman volume ls -q
[2024-05-02T18:23:00.980Z] Start: Run: podman ps -q -a --filter label=vsch.local.folder=/workspace/devcontainer --filter label=vsch.quality=stable
[2024-05-02T18:23:01.033Z] Stop (53 ms): Run: podman ps -q -a --filter label=vsch.local.folder=/workspace/devcontainer --filter label=vsch.quality=stable
[2024-05-02T18:23:01.033Z] Start: Run: podman ps -q -a --filter label=devcontainer.local_folder=/workspace/devcontainer --filter label=devcontainer.config_file=/workspace/devcontainer/.devcontainer/devcontainer.json
[2024-05-02T18:23:01.084Z] Stop (51 ms): Run: podman ps -q -a --filter label=devcontainer.local_folder=/workspace/devcontainer --filter label=devcontainer.config_file=/workspace/devcontainer/.devcontainer/devcontainer.json
[2024-05-02T18:23:01.085Z] Start: Run: podman ps -q -a --filter label=devcontainer.local_folder=/workspace/devcontainer
[2024-05-02T18:23:01.132Z] Stop (47 ms): Run: podman ps -q -a --filter label=devcontainer.local_folder=/workspace/devcontainer
[2024-05-02T18:23:01.133Z] Running Dev Containers CLI: read-configuration --docker-path podman --workspace-folder /workspace/devcontainer --id-label devcontainer.local_folder=/workspace/devcontainer --id-label devcontainer.config_file=/workspace/devcontainer/.devcontainer/devcontainer.json --log-level debug --log-format json --config /workspace/devcontainer/.devcontainer/devcontainer.json --mount-workspace-git-root
[2024-05-02T18:23:01.137Z] Start: Run: /home/user/.vscode-server/cli/servers/Stable-e170252f762678dec6ca2cc69aba1570769a5d39/server/node /home/user/.vscode-remote-containers/dist/dev-containers-cli-0.364.0/dist/spec-node/devContainersSpecCLI.js read-configuration --docker-path podman --workspace-folder /workspace/devcontainer --id-label devcontainer.local_folder=/workspace/devcontainer --id-label devcontainer.config_file=/workspace/devcontainer/.devcontainer/devcontainer.json --log-level debug --log-format json --config /workspace/devcontainer/.devcontainer/devcontainer.json --mount-workspace-git-root
[2024-05-02T18:22:33.993Z] @devcontainers/cli 0.59.1. Node.js v18.18.2. linux 6.5.0-26-generic x64.
[2024-05-02T18:22:33.993Z] Start: Run: git rev-parse --show-cdup
[2024-05-02T18:22:33.999Z] Stop (6 ms): Run: git rev-parse --show-cdup
[2024-05-02T18:22:33.999Z] Start: Run: podman ps -q -a --filter label=devcontainer.local_folder=/workspace/devcontainer --filter label=devcontainer.config_file=/workspace/devcontainer/.devcontainer/devcontainer.json
[2024-05-02T18:22:34.060Z] Stop (61 ms): Run: podman ps -q -a --filter label=devcontainer.local_folder=/workspace/devcontainer --filter label=devcontainer.config_file=/workspace/devcontainer/.devcontainer/devcontainer.json
[2024-05-02T18:23:01.332Z] Stop (195 ms): Run: /home/user/.vscode-server/cli/servers/Stable-e170252f762678dec6ca2cc69aba1570769a5d39/server/node /home/user/.vscode-remote-containers/dist/dev-containers-cli-0.364.0/dist/spec-node/devContainersSpecCLI.js read-configuration --docker-path podman --workspace-folder /workspace/devcontainer --id-label devcontainer.local_folder=/workspace/devcontainer --id-label devcontainer.config_file=/workspace/devcontainer/.devcontainer/devcontainer.json --log-level debug --log-format json --config /workspace/devcontainer/.devcontainer/devcontainer.json --mount-workspace-git-root
[2024-05-02T18:23:01.332Z] Running Dev Containers CLI: up --docker-path podman --container-session-data-folder /tmp/devcontainers-367081d6-f7c2-4b67-b279-70c5caf1896b1714674179538 --workspace-folder /workspace/devcontainer --workspace-mount-consistency cached --id-label devcontainer.local_folder=/workspace/devcontainer --id-label devcontainer.config_file=/workspace/devcontainer/.devcontainer/devcontainer.json --log-level debug --log-format json --config /workspace/devcontainer/.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
[2024-05-02T18:23:01.333Z] Start: Run: /home/user/.vscode-server/cli/servers/Stable-e170252f762678dec6ca2cc69aba1570769a5d39/server/node /home/user/.vscode-remote-containers/dist/dev-containers-cli-0.364.0/dist/spec-node/devContainersSpecCLI.js up --docker-path podman --container-session-data-folder /tmp/devcontainers-367081d6-f7c2-4b67-b279-70c5caf1896b1714674179538 --workspace-folder /workspace/devcontainer --workspace-mount-consistency cached --id-label devcontainer.local_folder=/workspace/devcontainer --id-label devcontainer.config_file=/workspace/devcontainer/.devcontainer/devcontainer.json --log-level debug --log-format json --config /workspace/devcontainer/.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
[2024-05-02T18:22:34.184Z] @devcontainers/cli 0.59.1. Node.js v18.18.2. linux 6.5.0-26-generic x64.
[2024-05-02T18:22:34.184Z] Start: Run: podman buildx version
[2024-05-02T18:22:34.274Z] Stop (90 ms): Run: podman buildx version
[2024-05-02T18:22:34.274Z] buildah 1.30.0
[2024-05-02T18:22:34.274Z]
[2024-05-02T18:22:34.274Z] Start: Run: podman -v
[2024-05-02T18:22:34.295Z] Stop (21 ms): Run: podman -v
[2024-05-02T18:22:34.295Z] Start: Resolving Remote
[2024-05-02T18:22:34.296Z] Start: Run: git rev-parse --show-cdup
[2024-05-02T18:22:34.300Z] Stop (4 ms): Run: git rev-parse --show-cdup
[2024-05-02T18:22:34.331Z] Start: Run: podman ps -q -a --filter label=devcontainer.local_folder=/workspace/devcontainer --filter label=devcontainer.config_file=/workspace/devcontainer/.devcontainer/devcontainer.json
[2024-05-02T18:22:34.428Z] Stop (97 ms): Run: podman ps -q -a --filter label=devcontainer.local_folder=/workspace/devcontainer --filter label=devcontainer.config_file=/workspace/devcontainer/.devcontainer/devcontainer.json
[2024-05-02T18:22:34.429Z] Start: Run: podman inspect --type image ubuntu:22.04
[2024-05-02T18:22:34.461Z] Stop (32 ms): Run: podman inspect --type image ubuntu:22.04
[2024-05-02T18:22:34.463Z] Start: Run: podman buildx build --load --build-arg BUILDKIT_INLINE_CACHE=1 -f /tmp/devcontainercli-user/container-features/0.59.1-1714674154461/Dockerfile-with-features -t vsc-devcontainer-d8c0c7e8a2f67c1109612cf1911a916d4db09871d414a1bed03be0a04cfe02e1 --target dev_containers_target_stage --build-arg _DEV_CONTAINERS_BASE_IMAGE=dev_container_auto_added_stage_label /workspace/devcontainer
[2024-05-02T18:22:34.488Z] [1/2] STEP 1/6: FROM ubuntu:22.04 AS dev_container_auto_added_stage_label
[2024-05-02T18:22:34.514Z] [1/2] STEP 2/6: RUN apt update && apt install -y systemd
[2024-05-02T18:22:34.516Z] --> Using cache f5a2ec43de43da365d822480fed63c80882b5921a06826206455a4d7be27e876
--> f5a2ec43de43
[2024-05-02T18:22:34.530Z] [1/2] STEP 3/6: RUN find /etc/systemd/system /lib/systemd/system -path '*.wants/*' -not -name '*journald*' -not -name '*systemd-tmpfiles*' -not -name '*systemd-user-sessions*' -exec rm \{} \;
[2024-05-02T18:22:34.531Z] --> Using cache fa2263f0df63c1bae393884a930e7d4ec09dc2e8008dcacee2f3f2c71ca0b46a
--> fa2263f0df63
[2024-05-02T18:22:34.546Z] [1/2] STEP 4/6: RUN find /etc/systemd/system/*.wants/ /lib/systemd/system/*.wants/ -type l \( -name 'e2scrub_all.timer' -o -name 'fstrim.timer' -o -name 'apt-daily.timer' -o -name 'apt-daily-upgrade.timer' -o -name 'dpkg-db-backup.timer' -o -name '[email protected]' -o -name 'getty-static.service' -o -name 'systemd-logind.service' -o -name 'systemd-user-sessions.service' -o -name 'systemd-modules-load.service' -o -name 'kmod-static-nodes.service' -o -name 'cryptsetup.target' -o -name 'remote-cryptsetup.target' -o -name 'veritysetup.target' -o -name 'remote-veritysetup.target' -o -name 'systemd-pstore.service' -o -name 'systemd-random-seed.service' -o -name 'dev-hugepages.mount' -o -name 'dev-mqueue.mount' -o -name 'sys-fs-fuse-connections.mount' \) -exec rm {} +
[2024-05-02T18:22:34.548Z] --> Using cache 2b9973c19b70161ceb8187d53e6d06f1c6504cec181ab6c6070fab055e438212
--> 2b9973c19b70
[2024-05-02T18:22:34.562Z] [1/2] STEP 5/6: RUN systemctl set-default multi-user.target
[2024-05-02T18:22:34.564Z] --> Using cache c47170476db4bcec131052830df7a152b0ded20c07ca97c80ce168bc959f8878
--> c47170476db4
[2024-05-02T18:22:34.578Z] [1/2] STEP 6/6: ENTRYPOINT [ "/lib/systemd/systemd", "--system", "--log-target=journal"]
[2024-05-02T18:22:34.581Z] --> Using cache 5954b66f0d2da04fa377c004499e81431bb17fc342327c84e69b9f8efec9ce58
--> 5954b66f0d2d
[2024-05-02T18:22:34.581Z] [2/2] STEP 1/2: FROM 5954b66f0d2da04fa377c004499e81431bb17fc342327c84e69b9f8efec9ce58 AS dev_containers_target_stage
[2024-05-02T18:22:34.595Z] [2/2] STEP 2/2: LABEL devcontainer.metadata="{\"overrideCommand\":false}"
[2024-05-02T18:22:34.597Z] --> Using cache d4668b676edcb6783c5359d30f17a2e69bea998789712734c902fd97e6e46b9a
[2/2] COMMIT vsc-devcontainer-d8c0c7e8a2f67c1109612cf1911a916d4db09871d414a1bed03be0a04cfe02e1
[2024-05-02T18:22:34.671Z] --> d4668b676edc
[2024-05-02T18:22:34.671Z] [Warning] one or more build args were not consumed: [BUILDKIT_INLINE_CACHE]
[2024-05-02T18:22:34.673Z] Successfully tagged localhost/vsc-devcontainer-d8c0c7e8a2f67c1109612cf1911a916d4db09871d414a1bed03be0a04cfe02e1:latest
[2024-05-02T18:22:34.678Z] d4668b676edcb6783c5359d30f17a2e69bea998789712734c902fd97e6e46b9a
[2024-05-02T18:22:34.682Z] Stop (219 ms): Run: podman buildx build --load --build-arg BUILDKIT_INLINE_CACHE=1 -f /tmp/devcontainercli-user/container-features/0.59.1-1714674154461/Dockerfile-with-features -t vsc-devcontainer-d8c0c7e8a2f67c1109612cf1911a916d4db09871d414a1bed03be0a04cfe02e1 --target dev_containers_target_stage --build-arg _DEV_CONTAINERS_BASE_IMAGE=dev_container_auto_added_stage_label /workspace/devcontainer
[2024-05-02T18:22:34.683Z] Start: Run: podman inspect --type image vsc-devcontainer-d8c0c7e8a2f67c1109612cf1911a916d4db09871d414a1bed03be0a04cfe02e1
[2024-05-02T18:22:34.765Z] Stop (82 ms): Run: podman inspect --type image vsc-devcontainer-d8c0c7e8a2f67c1109612cf1911a916d4db09871d414a1bed03be0a04cfe02e1
[2024-05-02T18:22:34.765Z] Start: Run: podman inspect --type image vsc-devcontainer-d8c0c7e8a2f67c1109612cf1911a916d4db09871d414a1bed03be0a04cfe02e1
[2024-05-02T18:22:34.798Z] Stop (33 ms): Run: podman inspect --type image vsc-devcontainer-d8c0c7e8a2f67c1109612cf1911a916d4db09871d414a1bed03be0a04cfe02e1
[2024-05-02T18:22:34.799Z] Start: Run: podman events --format json --filter event=start
[2024-05-02T18:22:34.801Z] Start: Starting container
[2024-05-02T18:22:34.801Z] Start: Run: podman run --sig-proxy=false -a STDOUT -a STDERR --mount type=bind,source=/workspace/devcontainer,target=/workspaces/devcontainer --mount type=volume,src=vscode,dst=/vscode -l devcontainer.local_folder=/workspace/devcontainer -l devcontainer.config_file=/workspace/devcontainer/.devcontainer/devcontainer.json --entrypoint /bin/sh vsc-devcontainer-d8c0c7e8a2f67c1109612cf1911a916d4db09871d414a1bed03be0a04cfe02e1 -c echo Container started
[2024-05-02T18:22:34.946Z] Container started
[2024-05-02T18:22:34.973Z] Start: Run: podman inspect --type container 8dedc275ed5e8cbd05cca3acffb951b29d50bd3e1c0373b5798d1c353d58e5f4
[2024-05-02T18:22:35.113Z] Stop (140 ms): Run: podman inspect --type container 8dedc275ed5e8cbd05cca3acffb951b29d50bd3e1c0373b5798d1c353d58e5f4
[2024-05-02T18:22:35.113Z] Stop (312 ms): Starting container
[2024-05-02T18:22:35.113Z] Start: Run: podman ps -q -a --filter label=devcontainer.local_folder=/workspace/devcontainer --filter label=devcontainer.config_file=/workspace/devcontainer/.devcontainer/devcontainer.json
[2024-05-02T18:22:35.116Z] Stop (315 ms): Run: podman run --sig-proxy=false -a STDOUT -a STDERR --mount type=bind,source=/workspace/devcontainer,target=/workspaces/devcontainer --mount type=volume,src=vscode,dst=/vscode -l devcontainer.local_folder=/workspace/devcontainer -l devcontainer.config_file=/workspace/devcontainer/.devcontainer/devcontainer.json --entrypoint /bin/sh vsc-devcontainer-d8c0c7e8a2f67c1109612cf1911a916d4db09871d414a1bed03be0a04cfe02e1 -c echo Container started
[2024-05-02T18:22:35.117Z] Stop (318 ms): Run: podman events --format json --filter event=start
[2024-05-02T18:22:35.203Z] Stop (90 ms): Run: podman ps -q -a --filter label=devcontainer.local_folder=/workspace/devcontainer --filter label=devcontainer.config_file=/workspace/devcontainer/.devcontainer/devcontainer.json
[2024-05-02T18:22:35.203Z] Start: Run: podman inspect --type container 8dedc275ed5e
[2024-05-02T18:22:35.235Z] Stop (32 ms): Run: podman inspect --type container 8dedc275ed5e
[2024-05-02T18:22:35.235Z] Start: Inspecting container
[2024-05-02T18:22:35.235Z] Start: Run: podman inspect --type container 8dedc275ed5e8cbd05cca3acffb951b29d50bd3e1c0373b5798d1c353d58e5f4
[2024-05-02T18:22:35.267Z] Stop (32 ms): Run: podman inspect --type container 8dedc275ed5e8cbd05cca3acffb951b29d50bd3e1c0373b5798d1c353d58e5f4
[2024-05-02T18:22:35.268Z] Stop (33 ms): Inspecting container
[2024-05-02T18:22:35.268Z] Start: Run in container: /bin/sh
[2024-05-02T18:22:35.271Z] Start: Run in container: uname -m
[2024-05-02T18:22:35.297Z] Stop (29 ms): Run in container: /bin/sh
[2024-05-02T18:23:02.564Z] Shell server terminated (code: 255, signal: null)
[2024-05-02T18:23:02.565Z] Error: can only create exec sessions on running containers: container state improper
[2024-05-02T18:22:35.297Z] Start: Run in container: (command -v getent >/dev/null 2>&1 && getent passwd 'root' || grep -E '^root|^[^:]*:[^:]*:root:' /etc/passwd || true)
[2024-05-02T18:22:35.297Z] Stdin closed!
[2024-05-02T18:23:02.565Z] Error: An error occurred setting up the container.
[2024-05-02T18:23:02.565Z] at ptA (/home/user/.vscode-remote-containers/dist/dev-containers-cli-0.364.0/dist/spec-node/devContainersSpecCLI.js:464:1260)
[2024-05-02T18:23:02.565Z] at NH (/home/user/.vscode-remote-containers/dist/dev-containers-cli-0.364.0/dist/spec-node/devContainersSpecCLI.js:464:1002)
[2024-05-02T18:23:02.565Z] at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
[2024-05-02T18:23:02.565Z] at async KtA (/home/user/.vscode-remote-containers/dist/dev-containers-cli-0.364.0/dist/spec-node/devContainersSpecCLI.js:481:3692)
[2024-05-02T18:23:02.566Z] at async $C (/home/user/.vscode-remote-containers/dist/dev-containers-cli-0.364.0/dist/spec-node/devContainersSpecCLI.js:481:4807)
[2024-05-02T18:23:02.566Z] at async hrA (/home/user/.vscode-remote-containers/dist/dev-containers-cli-0.364.0/dist/spec-node/devContainersSpecCLI.js:661:13255)
[2024-05-02T18:23:02.566Z] at async lrA (/home/user/.vscode-remote-containers/dist/dev-containers-cli-0.364.0/dist/spec-node/devContainersSpecCLI.js:661:12996)
[2024-05-02T18:23:02.569Z] Stop (1236 ms): Run: /home/user/.vscode-server/cli/servers/Stable-e170252f762678dec6ca2cc69aba1570769a5d39/server/node /home/user/.vscode-remote-containers/dist/dev-containers-cli-0.364.0/dist/spec-node/devContainersSpecCLI.js up --docker-path podman --container-session-data-folder /tmp/devcontainers-367081d6-f7c2-4b67-b279-70c5caf1896b1714674179538 --workspace-folder /workspace/devcontainer --workspace-mount-consistency cached --id-label devcontainer.local_folder=/workspace/devcontainer --id-label devcontainer.config_file=/workspace/devcontainer/.devcontainer/devcontainer.json --log-level debug --log-format json --config /workspace/devcontainer/.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
[2024-05-02T18:23:02.569Z] Exit code 1
[2024-05-02T18:23:02.571Z] Command failed: /home/user/.vscode-server/cli/servers/Stable-e170252f762678dec6ca2cc69aba1570769a5d39/server/node /home/user/.vscode-remote-containers/dist/dev-containers-cli-0.364.0/dist/spec-node/devContainersSpecCLI.js up --docker-path podman --container-session-data-folder /tmp/devcontainers-367081d6-f7c2-4b67-b279-70c5caf1896b1714674179538 --workspace-folder /workspace/devcontainer --workspace-mount-consistency cached --id-label devcontainer.local_folder=/workspace/devcontainer --id-label devcontainer.config_file=/workspace/devcontainer/.devcontainer/devcontainer.json --log-level debug --log-format json --config /workspace/devcontainer/.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
[2024-05-02T18:23:02.571Z] Exit code 1