athackst / vscode_ros2_workspace

A template for using VSCode as an IDE for ROS2 development.
https://althack.dev/vscode_ros2_workspace
Apache License 2.0
857 stars 177 forks source link

Change Docker Image #35

Closed Nils-ChristianIseke closed 2 years ago

Nils-ChristianIseke commented 2 years ago

I want to use the docker image moveit/moveit2:humble-source, when changin the line FROM althack/ros2:humble-dev to FROM moveit/moveit2:humble-source the container won't build. The following is the remoteContainers log. What do I need to do to change the docker image?

[2022-11-02T11:01:16.489Z] Dev Containers 0.255.4 in VS Code 1.72.2 (d045a5eda657f4d7b676dedbfa7aab8207f8a075).
[2022-11-02T11:01:16.489Z] Start: Resolving Remote
[2022-11-02T11:01:16.494Z] Setting up container for folder or workspace: /home/nils/vscode_ros2_workspace
[2022-11-02T11:01:16.497Z] Start: Check Docker is running
[2022-11-02T11:01:16.497Z] Start: Run: docker version --format {{.Server.APIVersion}}
[2022-11-02T11:01:16.513Z] Stop (16 ms): Run: docker version --format {{.Server.APIVersion}}
[2022-11-02T11:01:16.514Z] Server API version: 1.41
[2022-11-02T11:01:16.514Z] Stop (17 ms): Check Docker is running
[2022-11-02T11:01:16.514Z] Start: Run: docker volume ls -q
[2022-11-02T11:01:16.527Z] Stop (13 ms): Run: docker volume ls -q
[2022-11-02T11:01:16.531Z] Start: Run: docker ps -q -a --filter label=vsch.local.folder=/home/nils/vscode_ros2_workspace --filter label=vsch.quality=stable
[2022-11-02T11:01:16.542Z] Stop (11 ms): Run: docker ps -q -a --filter label=vsch.local.folder=/home/nils/vscode_ros2_workspace --filter label=vsch.quality=stable
[2022-11-02T11:01:16.543Z] Start: Run: docker ps -q -a --filter label=devcontainer.local_folder=/home/nils/vscode_ros2_workspace
[2022-11-02T11:01:16.555Z] Stop (12 ms): Run: docker ps -q -a --filter label=devcontainer.local_folder=/home/nils/vscode_ros2_workspace
[2022-11-02T11:01:16.556Z] Start: Run: /snap/code/111/usr/share/code/code --ms-enable-electron-run-as-node /home/nils/.vscode/extensions/ms-vscode-remote.remote-containers-0.255.4/dist/spec-node/devContainersSpecCLI.js up --user-data-folder /home/nils/.config/Code/User/globalStorage/ms-vscode-remote.remote-containers/data --workspace-folder /home/nils/vscode_ros2_workspace --workspace-mount-consistency cached --id-label devcontainer.local_folder=/home/nils/vscode_ros2_workspace --log-level debug --log-format json --config /home/nils/vscode_ros2_workspace/.devcontainer/devcontainer.json --default-user-env-probe loginInteractiveShell --mount type=volume,source=vscode,target=/vscode,external=true --skip-post-create --update-remote-user-uid-default on --mount-workspace-git-root true
[2022-11-02T11:01:16.717Z] (node:13142) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.
[2022-11-02T11:01:16.717Z] (Use `code --trace-deprecation ...` to show where the warning was created)
[2022-11-02T11:01:16.718Z] @devcontainers/cli 0.20.0. Node.js v16.14.2. linux 5.15.0-52-generic x64.
[2022-11-02T11:01:16.718Z] Start: Run: docker buildx version
[2022-11-02T11:01:16.759Z] Stop (41 ms): Run: docker buildx version
[2022-11-02T11:01:16.759Z] github.com/docker/buildx v0.9.1-docker ed00243a0ce2a0aee75311b06e32d33b44729689
[2022-11-02T11:01:16.759Z] 
[2022-11-02T11:01:16.759Z] Start: Resolving Remote
[2022-11-02T11:01:16.761Z] Start: Run: git rev-parse --show-cdup
[2022-11-02T11:01:16.764Z] Stop (3 ms): Run: git rev-parse --show-cdup
[2022-11-02T11:01:16.764Z] Start: Run: docker ps -q -a --filter label=devcontainer.local_folder=/home/nils/vscode_ros2_workspace
[2022-11-02T11:01:16.775Z] Stop (11 ms): Run: docker ps -q -a --filter label=devcontainer.local_folder=/home/nils/vscode_ros2_workspace
[2022-11-02T11:01:16.777Z] Start: Run: docker inspect --type image moveit/moveit2:humble-source
[2022-11-02T11:01:16.789Z] Stop (12 ms): Run: docker inspect --type image moveit/moveit2:humble-source
[2022-11-02T11:01:16.790Z] local container features stored at: /home/nils/.vscode/extensions/ms-vscode-remote.remote-containers-0.255.4/dist/node_modules/vscode-dev-containers/container-features
[2022-11-02T11:01:16.791Z] Start: Run: tar --no-same-owner -x -f -
[2022-11-02T11:01:16.803Z] Stop (12 ms): Run: tar --no-same-owner -x -f -
[2022-11-02T11:01:16.810Z] Start: Run: docker buildx build --load --build-arg BUILDKIT_INLINE_CACHE=1 -f /tmp/devcontainercli-nils/container-features/0.20.0-1667386876790/Dockerfile-with-features -t vsc-vscode_ros2_workspace-02943e7d9602e00c8f2428d00379df5a --target dev_containers_target_stage --build-arg WORKSPACE=/workspaces/vscode_ros2_workspace --build-context dev_containers_feature_content_source=/tmp/devcontainercli-nils/container-features/0.20.0-1667386876790 --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/nils/vscode_ros2_workspace/.devcontainer
[2022-11-02T11:01:16.953Z] [+] Building 0.0s (0/1)                                                         
[2022-11-02T11:01:17.104Z] [+] Building 0.2s (2/3)                                                         
 => [internal] load build definition from Dockerfile-with-features         0.0s
 => => transferring dockerfile: 1.64kB                                     0.0s
 => [internal] load .dockerignore                                          0.0s
[2022-11-02T11:01:17.104Z]  => => transferring context: 2B                                            0.0s
 => resolve image config for docker.io/docker/dockerfile:1.4               0.1s
[2022-11-02T11:01:17.254Z] [+] Building 0.3s (2/3)                                                         
 => [internal] load build definition from Dockerfile-with-features         0.0s
 => => transferring dockerfile: 1.64kB                                     0.0s
 => [internal] load .dockerignore                                          0.0s
 => => transferring context: 2B                                            0.0s
 => resolve image config for docker.io/docker/dockerfile:1.4               0.2s
[2022-11-02T11:01:17.405Z] [+] Building 0.5s (2/3)                                                         
 => [internal] load build definition from Dockerfile-with-features         0.0s
 => => transferring dockerfile: 1.64kB                                     0.0s
 => [internal] load .dockerignore                                          0.0s
 => => transferring context: 2B                                            0.0s
 => resolve image config for docker.io/docker/dockerfile:1.4               0.4s
[2022-11-02T11:01:17.512Z] [+] Building 0.6s (3/3)                                                         
 => [internal] load build definition from Dockerfile-with-features         0.0s
 => => transferring dockerfile: 1.64kB                                     0.0s
 => [internal] load .dockerignore                                          0.0s
 => => transferring context: 2B                                            0.0s
 => resolve image config for docker.io/docker/dockerfile:1.4               0.5s
[2022-11-02T11:01:17.637Z] [+] Building 0.7s (4/5)                                                         
 => [internal] load build definition from Dockerfile-with-features         0.0s
 => => transferring dockerfile: 1.64kB                                     0.0s
 => [internal] load .dockerignore                                          0.0s
 => => transferring context: 2B                                            0.0s
 => resolve image config for docker.io/docker/dockerfile:1.4               0.5s
 => CACHED docker-image://docker.io/docker/dockerfile:1.4@sha256:9ba7531b  0.0s
[2022-11-02T11:01:17.788Z] [+] Building 0.8s (10/12)                                                       
 => [internal] load build definition from Dockerfile-with-features         0.0s
 => => transferring dockerfile: 1.64kB                                     0.0s
 => [internal] load .dockerignore                                          0.0s
 => => transferring context: 2B                                            0.0s
 => resolve image config for docker.io/docker/dockerfile:1.4               0.5s
 => CACHED docker-image://docker.io/docker/dockerfile:1.4@sha256:9ba7531b  0.0s
 => [internal] load .dockerignore                                          0.0s
 => [internal] load build definition from Dockerfile-with-features         0.0s
 => [internal] load metadata for docker.io/moveit/moveit2:humble-source    0.0s
 => [context dev_containers_feature_content_source] load .dockerignore     0.0s
 => => transferring dev_containers_feature_content_source: 2B              0.0s
 => CACHED [dev_container_auto_added_stage_label 1/2] FROM docker.io/move  0.0s
 => [context dev_containers_feature_content_source] load from client       0.0s
 => => transferring dev_containers_feature_content_source: 3.21kB          0.0s
 => [dev_container_auto_added_stage_label 2/2] RUN echo "if [ -f /workspa  0.1s
[2022-11-02T11:01:17.915Z] [+] Building 1.0s (10/12)                                                       
 => [internal] load build definition from Dockerfile-with-features         0.0s
 => => transferring dockerfile: 1.64kB                                     0.0s
 => [internal] load .dockerignore                                          0.0s
 => => transferring context: 2B                                            0.0s
 => resolve image config for docker.io/docker/dockerfile:1.4               0.5s
 => CACHED docker-image://docker.io/docker/dockerfile:1.4@sha256:9ba7531b  0.0s
 => [internal] load .dockerignore                                          0.0s
 => [internal] load build definition from Dockerfile-with-features         0.0s
[2022-11-02T11:01:17.915Z]  => [internal] load metadata for docker.io/moveit/moveit2:humble-source    0.0s
 => [context dev_containers_feature_content_source] load .dockerignore     0.0s
 => => transferring dev_containers_feature_content_source: 2B              0.0s
 => CACHED [dev_container_auto_added_stage_label 1/2] FROM docker.io/move  0.0s
 => [context dev_containers_feature_content_source] load from client       0.0s
 => => transferring dev_containers_feature_content_source: 3.21kB          0.0s
 => [dev_container_auto_added_stage_label 2/2] RUN echo "if [ -f /workspa  0.2s
 => => # /bin/sh: 1: cannot create /home/ros/.bashrc: Directory nonexistent    
[2022-11-02T11:01:17.934Z] 
[2022-11-02T11:01:17.934Z] [+] Building 1.0s (11/12)                                                       
 => [internal] load build definition from Dockerfile-with-features         0.0s
 => => transferring dockerfile: 1.64kB                                     0.0s
 => [internal] load .dockerignore                                          0.0s
 => => transferring context: 2B                                            0.0s
 => resolve image config for docker.io/docker/dockerfile:1.4               0.5s
 => CACHED docker-image://docker.io/docker/dockerfile:1.4@sha256:9ba7531b  0.0s
 => [internal] load .dockerignore                                          0.0s
 => [internal] load build definition from Dockerfile-with-features         0.0s
 => [internal] load metadata for docker.io/moveit/moveit2:humble-source    0.0s
 => [context dev_containers_feature_content_source] load .dockerignore     0.0s
 => => transferring dev_containers_feature_content_source: 2B              0.0s
 => CACHED [dev_container_auto_added_stage_label 1/2] FROM docker.io/move  0.0s
 => [context dev_containers_feature_content_source] load from client       0.0s
 => => transferring dev_containers_feature_content_source: 3.21kB          0.0s
 => ERROR [dev_container_auto_added_stage_label 2/2] RUN echo "if [ -f /w  0.2s

------
 > [dev_container_auto_added_stage_label 2/2] RUN echo "if [ -f /workspaces/vscode_ros2_workspace/install/setup.bash ]; then source /workspaces/vscode_ros2_workspace/install/setup.bash; fi" >> /home/ros/.bashrc:
#0 0.213 /bin/sh: 1: cannot create /home/ros/.bashrc: Directory nonexistent
------
[2022-11-02T11:01:17.934Z] ERROR: failed to solve: executor failed running [/bin/sh -c echo "if [ -f ${WORKSPACE}/install/setup.bash ]; then source ${WORKSPACE}/install/setup.bash; fi" >> /home/ros/.bashrc]: exit code: 2
[2022-11-02T11:01:17.937Z] Stop (1127 ms): Run: docker buildx build --load --build-arg BUILDKIT_INLINE_CACHE=1 -f /tmp/devcontainercli-nils/container-features/0.20.0-1667386876790/Dockerfile-with-features -t vsc-vscode_ros2_workspace-02943e7d9602e00c8f2428d00379df5a --target dev_containers_target_stage --build-arg WORKSPACE=/workspaces/vscode_ros2_workspace --build-context dev_containers_feature_content_source=/tmp/devcontainercli-nils/container-features/0.20.0-1667386876790 --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/nils/vscode_ros2_workspace/.devcontainer
[2022-11-02T11:01:17.937Z] Error: Command failed: docker buildx build --load --build-arg BUILDKIT_INLINE_CACHE=1 -f /tmp/devcontainercli-nils/container-features/0.20.0-1667386876790/Dockerfile-with-features -t vsc-vscode_ros2_workspace-02943e7d9602e00c8f2428d00379df5a --target dev_containers_target_stage --build-arg WORKSPACE=/workspaces/vscode_ros2_workspace --build-context dev_containers_feature_content_source=/tmp/devcontainercli-nils/container-features/0.20.0-1667386876790 --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/nils/vscode_ros2_workspace/.devcontainer
[2022-11-02T11:01:17.937Z]     at Vse (/home/nils/.vscode/extensions/ms-vscode-remote.remote-containers-0.255.4/dist/spec-node/devContainersSpecCLI.js:1869:1635)
[2022-11-02T11:01:17.937Z]     at process.processTicksAndRejections (node:internal/process/task_queues:96:5)
[2022-11-02T11:01:17.937Z]     at async ZA (/home/nils/.vscode/extensions/ms-vscode-remote.remote-containers-0.255.4/dist/spec-node/devContainersSpecCLI.js:1868:1973)
[2022-11-02T11:01:17.937Z]     at async jO (/home/nils/.vscode/extensions/ms-vscode-remote.remote-containers-0.255.4/dist/spec-node/devContainersSpecCLI.js:1868:901)
[2022-11-02T11:01:17.937Z]     at async Xse (/home/nils/.vscode/extensions/ms-vscode-remote.remote-containers-0.255.4/dist/spec-node/devContainersSpecCLI.js:1874:2030)
[2022-11-02T11:01:17.937Z]     at async Uf (/home/nils/.vscode/extensions/ms-vscode-remote.remote-containers-0.255.4/dist/spec-node/devContainersSpecCLI.js:1874:3193)
[2022-11-02T11:01:17.938Z]     at async Cae (/home/nils/.vscode/extensions/ms-vscode-remote.remote-containers-0.255.4/dist/spec-node/devContainersSpecCLI.js:1994:10350)
[2022-11-02T11:01:17.938Z]     at async yae (/home/nils/.vscode/extensions/ms-vscode-remote.remote-containers-0.255.4/dist/spec-node/devContainersSpecCLI.js:1994:10104)
[2022-11-02T11:01:17.940Z] Stop (1384 ms): Run: /snap/code/111/usr/share/code/code --ms-enable-electron-run-as-node /home/nils/.vscode/extensions/ms-vscode-remote.remote-containers-0.255.4/dist/spec-node/devContainersSpecCLI.js up --user-data-folder /home/nils/.config/Code/User/globalStorage/ms-vscode-remote.remote-containers/data --workspace-folder /home/nils/vscode_ros2_workspace --workspace-mount-consistency cached --id-label devcontainer.local_folder=/home/nils/vscode_ros2_workspace --log-level debug --log-format json --config /home/nils/vscode_ros2_workspace/.devcontainer/devcontainer.json --default-user-env-probe loginInteractiveShell --mount type=volume,source=vscode,target=/vscode,external=true --skip-post-create --update-remote-user-uid-default on --mount-workspace-git-root true
[2022-11-02T11:01:17.940Z] Exit code 1
[2022-11-02T11:01:17.943Z] Command failed: /snap/code/111/usr/share/code/code --ms-enable-electron-run-as-node /home/nils/.vscode/extensions/ms-vscode-remote.remote-containers-0.255.4/dist/spec-node/devContainersSpecCLI.js up --user-data-folder /home/nils/.config/Code/User/globalStorage/ms-vscode-remote.remote-containers/data --workspace-folder /home/nils/vscode_ros2_workspace --workspace-mount-consistency cached --id-label devcontainer.local_folder=/home/nils/vscode_ros2_workspace --log-level debug --log-format json --config /home/nils/vscode_ros2_workspace/.devcontainer/devcontainer.json --default-user-env-probe loginInteractiveShell --mount type=volume,source=vscode,target=/vscode,external=true --skip-post-create --update-remote-user-uid-default on --mount-workspace-git-root true
[2022-11-02T11:01:17.943Z] Exit code 1
athackst commented 2 years ago

It looks like it’s failing on the ‘ros’ user not existing in your docker image. I would add the ‘ros’ user to the image to preserve running as non-root in the container.

See https://code.visualstudio.com/remote/advancedcontainers/add-nonroot-user for more info and https://github.com/athackst/dockerfiles/blob/main/template/snippits/ros_user.jinja for how I added a non root user to my containers.