I’m using VSCode Devcontainers to develop a micro-services application and I’ve been using a Java Devcontainer without issues.
But, given the micro-service nature of the project, there are other containers I need to execute (for instance, a postgres db).
This is the only container I use to develop, where I install Java-specific extensions, intellisense working, etc. I do NOT have this on my local machine nor do I want to have. Only when coding on the container.
Now, I did some research to shift the use of Devcontainers to docker-compose and start not only the Java devcontainer but also the database.
Everything seems to run fine.
However, the dev container will alway exit with code 137 and I can’t figure out why.
The structure of the code is as follows:
|.devcontainer
|--devcontainer.json
|--Dockerfile
|--docker-compose.yaml
|.git
|actionable-content
|--(my module code)
|db
|--Dockerfile
|--init.sql
|(...)
This is the output of the containers build commands:
[18 ms] Start: Resolving remote
[20 ms] Setting up container for folder or workspace: /Users/zed/Projects/circle-labs
[39 ms] Start: Check Docker is running
[39 ms] Start: Run: docker info
[401 ms] Start: Run: docker ps -q -a --filter label=com.docker.compose.project=evooq-circle --filter label=com.docker.compose.service=dev-container
[444 ms] Start: Run: docker inspect --type container ea365c78bc6d
[490 ms] Start: Removing existing container.
[490 ms] Start: Run: docker rm -f ea365c78bc6d229737805fe4121324b45c87688ccd369bccebf209689f2658d7
[611 ms] Start: Run: docker-compose -f /Users/zed/Projects/circle-labs/.devcontainer/docker-compose.yaml config --services
[1027 ms] Start: Run: docker events --format {{json .}} --filter status=start
[1032 ms] Start: Run: docker-compose --project-name evooq-circle -f /Users/zed/Projects/circle-labs/.devcontainer/docker-compose.yaml up -d --build db dev-container
Building db
Step 1/2 : FROM postgres:9.6
---> 16f0ba6ed857
Step 2/2 : COPY init.sql /docker-entrypoint-initdb.d/
---> Using cache
---> e90f4e0c7c73
Successfully built e90f4e0c7c73
Successfully tagged evooq-circle_db:latest
Building dev-container
Step 1/15 : FROM openjdk:11-jdk
---> a548e8a50190
Step 2/15 : ARG USERNAME=vscode
---> Using cache
---> bd1352aa5e59
Step 3/15 : ARG USER_UID=1000
---> Using cache
---> 192dca586afc
Step 4/15 : ARG USER_GID=$USER_UID
---> Using cache
---> 91a3124b064c
Step 5/15 : ENV DEBIAN_FRONTEND=noninteractive
---> Using cache
---> 222b620a3e1b
Step 6/15 : RUN apt-get update && apt-get -y install --no-install-recommends apt-utils dialog 2>&1 && groupadd --gid $USER_GID $USERNAME && useradd -s /bin/bash --uid $USER_UID --gid $USER_GID -m $USERNAME && apt-get install -y sudo && echo $USERNAME ALL=(root) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME && chmod 0440 /etc/sudoers.d/$USERNAME && apt-get -y install git openssh-client less iproute2 procps curl lsb-release
---> Using cache
---> 8ad502a168f4
Step 7/15 : ARG MAVEN_VERSION=3.6.3
---> Using cache
---> 2f0fed0ae029
Step 8/15 : ARG MAVEN_SHA=c35a1803a6e70a126e80b2b3ae33eed961f83ed74d18fcd16909b2d44d7dada3203f1ffe726c17ef8dcca2dcaa9fca676987befeadc9b9f759967a8cb77181c0
---> Using cache
---> ba172229c081
Step 9/15 : RUN mkdir -p /usr/share/maven /usr/share/maven/ref && curl -fsSL -o /tmp/apache-maven.tar.gz https://archive.apache.org/dist/maven/maven-3/${MAVEN_VERSION}/binaries/apache-maven-${MAVEN_VERSION}-bin.tar.gz && echo "${MAVEN_SHA} /tmp/apache-maven.tar.gz" | sha512sum -c - && tar -xzf /tmp/apache-maven.tar.gz -C /usr/share/maven --strip-components=1 && rm -f /tmp/apache-maven.tar.gz && ln -s /usr/share/maven/bin/mvn /usr/bin/mvn
---> Using cache
---> 033989c61d1f
Step 10/15 : COPY maven-settings.xml /usr/share/maven/ref/
---> Using cache
---> 5dcb163d3198
Step 11/15 : ENV MAVEN_HOME /usr/share/maven
---> Using cache
---> 9c21dcb2fa42
Step 12/15 : ENV MAVEN_CONFIG /root/.m2
---> Using cache
---> 56960418c145
Step 13/15 : RUN apt-get autoremove -y && apt-get clean -y && rm -rf /var/lib/apt/lists/*
---> Using cache
---> 939839f8b869
Step 14/15 : ENV DEBIAN_FRONTEND=dialog
---> Using cache
---> da8ceada8e6f
Step 15/15 : RUN if [ ! -d "/docker-java-home" ]; then ln -s "${JAVA_HOME}" /docker-java-home; fi
---> Using cache
---> 8781e2f051b0
Successfully built 8781e2f051b0
Successfully tagged evooq-circle_dev-container:latest
evooq-circle_db_1 is up-to-date
Creating evooq-circle_dev-container_1 ... done
[2449 ms] Start: Run: docker ps -q -a --filter label=com.docker.compose.project=evooq-circle --filter label=com.docker.compose.service=dev-container
[2507 ms] Start: Run: docker inspect --type container f11a0e8f78c2
[2555 ms] Start: Inspecting container
[2555 ms] Start: Run: docker inspect --type container f11a0e8f78c28d23046be8ff36fa28a18bc2d1147d24bd04f3aac39f7d02cb49
[2609 ms] Start: Run: docker exec -i -u root -e VSCODE_REMOTE_CONTAINERS_SESSION=190e175e-f482-4554-aaf4-e062c672fcdb1593105541203 f11a0e8f78c28d23046be8ff36fa28a18bc2d1147d24bd04f3aac39f7d02cb49 /bin/sh
[2614 ms] Start: Run in container: uname -m
[2753 ms] x86_64
[2753 ms]
[2753 ms] Start: Run in container: (cat /etc/os-release || cat /usr/lib/os-release) 2>/dev/null
[2761 ms] PRETTY_NAME="Debian GNU/Linux 10 (buster)"
NAME="Debian GNU/Linux"
VERSION_ID="10"
VERSION="10 (buster)"
VERSION_CODENAME=buster
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"
[2761 ms]
[2761 ms] Start: Run in container: cat /etc/passwd
[2765 ms] Start: Updating configuration state
[2770 ms] Start: Setup shutdown monitor
[2773 ms] Forking shutdown monitor: /Users/zed/.vscode/extensions/ms-vscode-remote.remote-containers-0.122.1/dist/shutdownMonitorProcess /var/folders/bp/bjk1_4fs2ljdx8pflq89nd500000gn/T/vscode-remote-containers-e8ace0f38179417fa6822e6d83141fd504155ae0.sock dockerCompose Info /Users/zed/Library/Application Support/Code/logs/20200625T091545/exthost3/ms-vscode-remote.remote-containers
[2779 ms] Start: Run in container: test -d /root/.vscode-server
[2785 ms]
[2785 ms]
[2785 ms] Exit code 1
[2785 ms] Start: Run in container: test -d /root/.vscode-remote
[2788 ms]
[2788 ms]
[2788 ms] Exit code 1
[2788 ms] Start: Run in container: set -o noclobber ; mkdir -p '/root/.vscode-server/data/Machine' && { > '/root/.vscode-server/data/Machine/.writeMachineSettingsMarker' ; } 2> /dev/null
[2797 ms]
[2797 ms]
[2797 ms] Start: Run in container: mkdir -p '/root/.vscode-server/data/Machine' && cat >'/root/.vscode-server/data/Machine/settings.json' <<'settingsJSON'
[2804 ms]
[2804 ms]
[2804 ms] Start: Run in container: test -d /root/.vscode-server/bin/cd9ea6488829f560dc949a8b2fb789f3cdc05f5d
[2806 ms]
[2806 ms]
[2806 ms] Exit code 1
[2807 ms] Installing VS Code Server for commit cd9ea6488829f560dc949a8b2fb789f3cdc05f5d
[2807 ms] Start: Run in container: mkdir -p /root/.vscode-server/bin/cd9ea6488829f560dc949a8b2fb789f3cdc05f5d_1593105545145
[2811 ms]
[2811 ms]
[2812 ms] Start: Run: docker exec -i -u root -w /root/.vscode-server/bin/cd9ea6488829f560dc949a8b2fb789f3cdc05f5d_1593105545145 f11a0e8f78c28d23046be8ff36fa28a18bc2d1147d24bd04f3aac39f7d02cb49 tar --no-same-owner -xz --strip-components 1
[5305 ms]
[5306 ms]
[5306 ms] Start: Run in container: mv -n /root/.vscode-server/bin/cd9ea6488829f560dc949a8b2fb789f3cdc05f5d_1593105545145 /root/.vscode-server/bin/cd9ea6488829f560dc949a8b2fb789f3cdc05f5d
[5317 ms]
[5317 ms]
[5317 ms] Start: Launching Remote-Containers helper.
[5318 ms] Start: Run: gpgconf --list-dir agent-extra-socket
[5343 ms] Start: Run in container: gpgconf --list-dir agent-socket
[5348 ms] /root/.gnupg/S.gpg-agent
[5348 ms]
[5348 ms] Start: Run in container: mkdir -p -m 700 '/root/.gnupg'
[5356 ms]
[5356 ms]
[5356 ms] Start: Run in container: # Copy /Users/zed/.gitconfig to /root/.gitconfig
[5356 ms] Start: Run: gpgconf --list-dir homedir
[5369 ms]
[5369 ms]
[5369 ms] Start: Run in container: cat <<'EOF-/tmp/vscode-remote-containers-f97cc7a21081e70e2303f2544443a16dbafee09f.js' >/tmp/vscode-remote-containers-f97cc7a21081e70e2303f2544443a16dbafee09f.js
[5382 ms]
[5382 ms]
[5382 ms] Start: Run in container: gpgconf --list-dir homedir
[5401 ms] /root/.gnupg
[5401 ms]
[5401 ms] Start: Run in container: command -v git >/dev/null 2>&1 && git config --global credential.helper '!f() { /root/.vscode-server/bin/cd9ea6488829f560dc949a8b2fb789f3cdc05f5d/node /tmp/vscode-remote-containers-f97cc7a21081e70e2303f2544443a16dbafee09f.js $*; }; f' || true
[5419 ms]
[5419 ms]
[5420 ms] Start: Run in container: cat <<'EOF-/tmp/vscode-remote-containers-server-f97cc7a21081e70e2303f2544443a16dbafee09f.js' >/tmp/vscode-remote-containers-server-f97cc7a21081e70e2303f2544443a16dbafee09f.js
[5442 ms]
[5442 ms]
[5443 ms] Start: Run in container: # Copy /Users/zed/.gnupg/pubring.kbx to /root/.gnupg/pubring.kbx
[5445 ms] Start: Run: docker exec -i -u root -e REMOTE_CONTAINERS_SOCKETS=["/tmp/vscode-ssh-auth-f97cc7a21081e70e2303f2544443a16dbafee09f.sock","/root/.gnupg/S.gpg-agent"] -e REMOTE_CONTAINERS_IPC=/tmp/vscode-remote-containers-ipc-f97cc7a21081e70e2303f2544443a16dbafee09f.sock f11a0e8f78c28d23046be8ff36fa28a18bc2d1147d24bd04f3aac39f7d02cb49 /root/.vscode-server/bin/cd9ea6488829f560dc949a8b2fb789f3cdc05f5d/node /tmp/vscode-remote-containers-server-f97cc7a21081e70e2303f2544443a16dbafee09f.js
[5482 ms]
[5482 ms]
[5482 ms] Start: Run in container: set -o noclobber ; mkdir -p '/root/.vscode-server/data/Machine' && { > '/root/.vscode-server/data/Machine/.installExtensionsMarker' ; } 2> /dev/null
[5494 ms]
[5494 ms]
[5494 ms] Start: Run in container: # Copy /Users/zed/.gnupg/trustdb.gpg to /root/.gnupg/trustdb.gpg
[5529 ms]
[5529 ms]
[5529 ms] Start: Run in container: test -d /root/.vscode-server/extensionsCache && ls /root/.vscode-server/extensionsCache || true
[5530 ms] Start: Run: gpg-connect-agent updatestartuptty /bye
[5536 ms]
[5536 ms]
[5539 ms] Start: Run in container: mkdir -p /root/.vscode-server/extensionsCache/tmp-1593105547877
[5553 ms]
[5553 ms]
[5553 ms] Start: Run: docker exec -i -u root -w /root/.vscode-server/extensionsCache/tmp-1593105547877 f11a0e8f78c28d23046be8ff36fa28a18bc2d1147d24bd04f3aac39f7d02cb49 tar x --strip-components 1
[6353 ms] Start: Run in container: mv /root/.vscode-server/extensionsCache/tmp-1593105547877/* /root/.vscode-server/extensionsCache && rmdir /root/.vscode-server/extensionsCache/tmp-1593105547877
[6393 ms]
[6394 ms]
[6394 ms] Start: Run in container: cd /root/.vscode-server/bin/cd9ea6488829f560dc949a8b2fb789f3cdc05f5d; export VSCODE_AGENT_FOLDER=/root/.vscode-server; /root/.vscode-server/bin/cd9ea6488829f560dc949a8b2fb789f3cdc05f5d/server.sh --extensions-download-dir /root/.vscode-server/extensionsCache --install-extension vscjava.vscode-java-pack --install-extension pivotal.vscode-boot-dev-pack --install-extension github.vscode-pull-request-github --install-extension kumar-harsh.graphql-for-vscode --install-extension zxh404.vscode-proto3 --install-extension humao.rest-client --force
[6704 ms] Start: Run in container: ls /root/.vscode-server/extensionsCache
[6704 ms] Stdin closed!
[6706 ms] Shell server terminated (code: 137, signal: null)
[6747 ms] Remote-Containers server terminated (code: 137, signal: null).
I suspect the issue may lie in the extensions installation process, but I’m not entirely sure.
Anyway, I went from this combination of devcontainer.json
+ Dockerfile
here (gist), to the combination of devcontainer.json
+ docker-compose.yaml
+ Dockerfile
, that are here (another gist).
What could be causing the errors above? I’m really lost here as I don’t see a reason.
Also, I suspect I need the runArgs from the initial version but they seem not to be supported when using docker-compose mode.
Thanks
2
Answers
Well, for any of you that end up here looking here, here's what I changed that did the trick:
On my
docker-compose.yaml
I added the following:On the
Dockerfile
I added aCMD
to the end as well:Then, rebuild the image, and it should work.
Also, regarding the
runArgs
, I added this to mydocker-compose.yaml
file:These additions/modifications should do the trick for you as well
This is the command I always use in any Dockerfile for VSCode: