I'm working on a project that has a build set up in GitHub Actions using Docker. I want to set up the same build on my local machine using VS Code. I created the .devcontainer
directory and put the Dockerfile of the Docker image in there. It's reasonably basic, just Ubuntu 20.04 along with some packages:
FROM ubuntu:20.04
#install general package
RUN apt update && apt -y upgrade && apt -y dist-upgrade && apt -y autoremove
RUN apt install -y wget software-properties-common openssl libssl-dev vim curl
#install aarch64 compile
RUN apt install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu sudo build-essential
I created a basic devcontainer.json
file:
{
"name": "Build",
"build": {
"dockerfile": "Dockerfile",
"context" : ".."
}
}
But when I open this using the command "Dev Containers: Open Folder in Container..." it fails with:
[2025-04-07T01:26:03.807Z] [+] Building 0.0s (0/0) docker:default
[2025-04-07T01:26:03.808Z] ERROR: resolve : lstat /tmp/devcontainercli-tom: no such file or directory
[2025-04-07T01:26:03.812Z] Stop (164 ms): Run: docker buildx build --load --build-arg BUILDKIT_INLINE_CACHE=1 -f /tmp/devcontainercli-tom/container-features/0.75.0-1743989163646/Dockerfile-with-features -t vsc-my-project-0e7daada5b87192d14f17d6429b5122695a3e1282fb7f39ca188f42b196e63b1 --target dev_containers_target_stage --build-arg _DEV_CONTAINERS_BASE_IMAGE=dev_container_auto_added_stage_label /home/tom/Documents/GitHub/MyProject
The directory /tmp/devcontainercli-tom
exists so where am I going wrong?
Finally found the problem. Turns out I had Docker installed with Snap and there's a limitation where Snap can't access /tmp: https://github.com/canonical/docker-snap/issues/34#issuecomment-812045834
I had to uninstall Docker from Snap and reinstall using apt-get and now it works: https://docs.docker.com/engine/install/ubuntu/