I am trying to learn codespaces and I have the following dockerfile:
FROM mcr.microsoft.com/vscode/devcontainers/base:debian-11
RUN apt update -y; \
apt install python3-pip -y
COPY .devcontainer/req.txt /usr/local/bin/.
RUN pip3 install --no-cache-dir -r /usr/bin/req.txt
but bizzarely the copy always seem to fails with this error:
#9 ERROR: failed to walk /var/lib/docker/tmp/buildkit-mount3300366747/.devcontainer: lstat /var/lib/docker/tmp/buildkit-mount3300366747/.devcontainer: no such file or directory
What is going on? I am baffled!
When I look at the rescue container, I do see the file intact under .devcontainer
my tree is lie so:
-src
-.devcontainer
-Dockerfile
- devcontainer.json
- req.txt
- main.py
and in my devcontainer.json, I have:
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/debian
{
"name": "Debian",
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
// "image": "mcr.microsoft.com/devcontainers/base:${templateOption:imageVariant}"
"build": {
// Path is relataive to the devcontainer.json file.
"dockerfile": "Dockerfile"
}
// Features to add to the dev container. More info: https://containers.dev/features.
// "features": {},
// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],
// Configure tool-specific properties.
// "customizations": {},
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
// "remoteUser": "root"
}
Looking at your posted directory structure, I see that your Dockerfile
is actually inside the .devcontainer
directory you are referring to in your COPY
command. That's not allowed, so either
COPY req.txt /usr/local/bin/
or
Dockerfile
one directory up and call docker build
from there (note, that moving your docker file may break other steps of your build chain)