Codespaces fails with Alpine devcontainer

I have a repo that sets up an environment with Alpine Linux. I’m getting “The codespace failed” error even though the container successfully builds (see the log below) and “Run container” step shows the green check mark.


.devcontainer/devcontainer.json
{
	"name": "Codespaces",
	"dockerFile": "Dockerfile",
}
.devcontainer/Dockerfile
FROM alpine:3.12.0
RUN apk add --no-cache bash
Build Log
$ Waiting for output...
COMMAND: chmod o+rw "/var/lib/docker/vsonlinemount/workspace"
Started: 2020-09-12T20:05:02
chmod process exited with exit code 0
Finished: 2020-09-12T20:05:02
COMMAND: setfacl -dR -m u::rwX,g::rwX,o::rwX "/var/lib/docker/vsonlinemount/workspace"
Started: 2020-09-12T20:05:02
setfacl process exited with exit code 0
Finished: 2020-09-12T20:05:02




Configuration starting...
COMMAND: git ls-remote https://github.com/[[REDACTED]] heads/master
Started: 2020-09-12T20:05:02
fatal: could not read Username for 'https://github.com': terminal prompts disabled
git process exited with exit code 128
Finished: 2020-09-12T20:05:04
COMMAND: git -C "/var/lib/docker/vsonlinemount/workspace" clone https://github.com/[[REDACTED]] "/var/lib/docker/vsonlinemount/workspace/codespaces"
Started: 2020-09-12T20:05:04
Cloning into '/var/lib/docker/vsonlinemount/workspace/codespaces'...
git process exited with exit code 0
Finished: 2020-09-12T20:05:07

COMMAND: docker build -t cloudenvimage -f /var/lib/docker/vsonlinemount/workspace/codespaces/.devcontainer/Dockerfile /var/lib/docker/vsonlinemount/workspace/codespaces/.devcontainer
Started: 2020-09-12T20:05:07

Sending build context to Docker daemon  3.072kB
Step 1/2 : FROM alpine:3.12.0
3.12.0: Pulling from library/alpine
df20fa9351a1: Pulling fs layer
df20fa9351a1: Download complete
df20fa9351a1: Pull complete
Digest: sha256:185518070891758909c9f839cf4ca393ee977ac378609f700f60a771a2dfe321
Status: Downloaded newer image for alpine:3.12.0
 ---> a24bb4013296
Step 2/2 : RUN apk add --no-cache bash
 ---> Running in b2c9eac086be
fetch http://dl-cdn.alpinelinux.org/alpine/v3.12/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.12/community/x86_64/APKINDEX.tar.gz
(1/4) Installing ncurses-terminfo-base (6.2_p20200523-r0)
(2/4) Installing ncurses-libs (6.2_p20200523-r0)
(3/4) Installing readline (8.0.4-r0)
(4/4) Installing bash (5.0.17-r0)
Executing busybox-1.31.1-r16.trigger
Executing bash-5.0.17-r0.post-install
OK: 8 MiB in 18 packages
Removing intermediate container b2c9eac086be
Successfully tagged cloudenvimage:latest
 ---> 59ea5c8086c2
Successfully built 59ea5c8086c2
docker process exited with exit code 0
Finished: 2020-09-12T20:05:13
COMMAND: docker create --restart=on-failure:10 -v /root/.vsonline/.vsoshared:/root/.vsonline/.vsoshared -v /.vsonline/vsoagent/mount:/.vsonline/bin -v /var/lib/docker/vsonlinemount/workspace:/root/workspace --name codespaces_82af7f --hostname codespaces_82af7f --add-host codespaces_82af7f:127.0.0.1 --label Type=vsonline --label StartCLI=True --label User=root --label ContainerVersion=5 --init -v /mnt/containerTmp:/tmp --entrypoint /bin/sh --network host -e "CODESPACES=true" cloudenvimage -c "while sleep 1000; do :; done"
Started: 2020-09-12T20:05:13
761784a41eea9f76b65ae170a38b81aee0150bd3db5c17b24ac24b2cfe97656e
docker process exited with exit code 0
Finished: 2020-09-12T20:05:13
COMMAND: docker start codespaces_82af7f
Started: 2020-09-12T20:05:13
docker process exited with exit code 0
codespaces_82af7f
Finished: 2020-09-12T20:05:13
COMMAND: docker exec -u root codespaces_82af7f /.vsonline/bin/Docker/linux-prereqs.sh true false false true
Started: 2020-09-12T20:05:13
Visual Studio Online requires a number of prerequisites that this script

#See https://aka.ms/vsls-docs/linux-prerequisites


Visual Studio Online Linux Dependency Installer

fetch http://dl-cdn.alpinelinux.org/alpine/v3.12/main/x86_64/APKINDEX.tar.gz
(*) Detected Alpine Linux

(*) Updating and upgrading...
will attempt to install for you. This process requires admin / root access.
fetch http://dl-cdn.alpinelinux.org/alpine/v3.12/community/x86_64/APKINDEX.tar.gz
v3.12.0-313-g23f4082141 [http://dl-cdn.alpinelinux.org/alpine/v3.12/main]
OK: 12746 distinct packages available
v3.12.0-310-gfeadd8fa34 [http://dl-cdn.alpinelinux.org/alpine/v3.12/community]

(*) Verifying .NET Core dependencies...
fetch http://dl-cdn.alpinelinux.org/alpine/v3.12/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.12/community/x86_64/APKINDEX.tar.gz
(2/11) Installing libstdc++ (9.3.0-r2)
(1/11) Installing libgcc (9.3.0-r2)
(3/11) Installing icu-libs (67.1-r0)
(4/11) Installing icu (67.1-r0)
(5/11) Installing krb5-conf (1.0-r2)
(6/11) Installing libcom_err (1.45.6-r0)
(7/11) Installing keyutils-libs (1.6.1-r1)
(9/11) Installing krb5-libs (1.18.2-r0)
(8/11) Installing libverto (0.3.1-r1)
(10/11) Installing e2fsprogs-libs (1.45.6-r0)
(11/11) Installing krb5 (1.18.2-r0)
Executing busybox-1.31.1-r16.trigger
OK: 44 MiB in 29 packages
(*) Verifying VSOnline dependencies...

fetch http://dl-cdn.alpinelinux.org/alpine/v3.12/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.12/community/x86_64/APKINDEX.tar.gz
(1/9) Installing ca-certificates (20191127-r4)
(2/9) Installing nghttp2-libs (1.41.0-r0)
(4/9) Installing expat (2.2.9-r1)
(3/9) Installing libcurl (7.69.1-r0)
(6/9) Installing git (2.26.2-r0)
(5/9) Installing pcre2 (10.35-r0)
(7/9) Installing libunistring (0.9.10-r0)
(8/9) Installing libidn2 (2.3.0-r0)
(9/9) Installing wget (1.20.3-r1)
Executing busybox-1.31.1-r16.trigger
Executing ca-certificates-20191127-r4.trigger
OK: 63 MiB in 38 packages
(*) Success!


docker process exited with exit code 0
Finished: 2020-09-12T20:05:14
COMMAND: docker exec -u root codespaces_82af7f chown -R root /.vsonline/bin
Started: 2020-09-12T20:05:14
docker process exited with exit code 0
Finished: 2020-09-12T20:05:14
COMMAND: docker exec -u root codespaces_82af7f chown -R root /root/.vsonline
Started: 2020-09-12T20:05:15
docker process exited with exit code 0
Finished: 2020-09-12T20:05:15
COMMAND: docker exec -u root codespaces_82af7f mkdir -p /root/workspace/codespaces
Started: 2020-09-12T20:05:15
docker process exited with exit code 0
Finished: 2020-09-12T20:05:15

Starting Codespace...

Hey! We don’t currently support Alphine-based containers, due to some dependencies that are missing from that distro. We’re hoping to fix this soon, but in the meantime, you’ll need to use a different base.

In your case, would you be able to get by without a custom Dockerfile? Codespaces provides a default image that is preloaded with SDKs for .NET Core, PHP, Python, Node.js, Go, Ruby, Java and Rust, and a bunch of other tools (e.g bash, Fish, Zsh, Git, etc.). So if you simply remove the dockerFile property from your devcontainer.json file, you may be able to get by successfully?

If you do need a custom Dockerfile (e.g. to add a few additional dependencies), you could try deriving from the base Codespaces image (mcr.microsoft.com/vscode/devcontainers/universal:linux), or from a non-Alpine distro (e.g. debian, etc.)

Let us know if any of that is helpful and/or what other constraints you might have, so we can think about other near-term workarounds. Other than that, we hope to support Alpine containers soon :+1:

Would you consider documenting what dependencies are required, be it which popular base images are supported or which libraries in linux are required? I’ve been running several devcontainers locally on Windows and linux and success that don’t work on Codespaces, and crafting my own fast-building small container images has been truly trying. I’ve been working on one most of the morning. I’m drawing from other contains that work, but taking a dependency on the aforementioned, multi-GB image is not a compromise I want to make (drags down local development times, even if it would speed up Codespaces since I’m assuming that image is already cached).

Alpine is not supported yet, but generally Ubuntu and Debian based images - which make up the bulk of Docker base images work. The issue with Alpine is it is non-glibc based which means its not binary compatible with Debian/CentOS/RHEL/others. For example, “node” works, “node:alpine” does not currently. Eventually there will be support, but extension support will be mixed.

Note that if you do anything like “bind mounts” locally, those would not work in a Codespace, so that can be a common source of problems for local vs Codespaces.

The core requirements are the same as VS Code Remote Development here: https://code.visualstudio.com/docs/remote/linux#_remote-host-container-wsl-linux-prerequisites

Alpine is the one variation right now verses the Remote Development extensions.

If you’re looking for a reasonable starting point that includes git and other development tools, you may want to try mcr.microsoft.com/vscode/devcontainers/base:buster There’s others here: https://hub.docker.com/_/microsoft-vscode-devcontainers

Their contents generally descend from a Docker base image and their Dockerfiles can be all found at https://github.com/microsoft/vscode-dev-containers.