0

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?

2 Answers 2

0

Try removing the "context" : ".." from devcontainer.json. Your docker file is inside .devcontainer directory. I assume so is devcontainer.json.

Sign up to request clarification or add additional context in comments.

4 Comments

I added that to see if it fixed the problem; removing it doesn't.
I tried and could open any local folder in the container without any issue. Can you try any other local folder in the container?
I'm not sure what you mean? The container isn't created.
If it has not been created then how could you have option Dev Containers: Open Folder in Container...? Once container is created that allows you to open a loca directory (where your code exists) to open in the container. Try to open a folder that exists in your local.
0

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/

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.