skip to Main Content

i’m doing a tutorial in docker, and trying to copy a image from docker, and reference the index.hmtl file im my local file,
vinnyx05 -> is my login at docker, im running docker desktop.
in using Windows 11.
the code is:

PS C:html> docker build -t vinnyx5/nginx-imersao13:latest . 
[+] Building 0.2s (6/6) FINISHED
 => [internal] load build definition from Dockerfile                                                                                         0.1s 
 => => transferring dockerfile: 101B                                                                                                         0.0s 
 => [internal] load .dockerignore                                                                                                            0.1s 
 => => transferring context: 2B                                                                                                              0.0s 
 => [internal] load metadata for docker.io/library/nginx:latest                                                                              0.0s 
 => [internal] load build context                                                                                                            0.0s 
 => => transferring context: 2B                                                                                                              0.0s 
 => CACHED [1/2] FROM docker.io/library/nginx:latest                                                                                         0.0s 
 => ERROR [2/2] COPY html/index.html /usr/share/nginx/html/                                                                                  0.0s 
------
 > [2/2] COPY html/index.html /usr/share/nginx/html/:
------
Dockerfile:3
--------------------
   1 |     FROM nginx:latest
   2 |
   3 | >>> COPY html/index.html /usr/share/nginx/html/
--------------------
ERROR: failed to solve: failed to compute cache key: failed to calculate checksum of ref ccf5a995-3d05-4517-a1ee-20291664f134::ljszgt44a3wte8c2sal6f54p2: failed to walk /var/lib/docker/tmp/buildkit-mount2559770106/html: lstat /var/lib/docker/tmp/buildkit-mount2559770106/html: no such file or directory

i dont know how to fix this, help please?
Thanks =)

im trying to do a copy of image, and edit de index.html locally

3

Answers


  1. Docker cannot find the file html/index.html.

    Probably, in relation to your folder structure, you should copy the file like this:

    COPY ./html/index.html /usr/share/nginx/html
    
    Login or Signup to reply.
  2. Make sure you’re running over a linux based terminal (like WSL). It seems to be a "windows" issue.

    Login or Signup to reply.
  3. You are building from inside the html folder with:

    PS C:html> docker build -t vinnyx5/nginx-imersao13:latest . 
    

    The build context in that command is . or the current directory.

    You then attempt to copy the file html/index.html from that context to the image with:

    COPY html/index.html /usr/share/nginx/html/
    

    For that to work, the file C:htmlhtmlindex.html needs to exist (note the double html in the path).

    To fix this, either change your context to be a directory higher (not recommended since you are working just under c: and you don’t want to copy the entire C drive to the docker temp directory which is frequently on the C drive). Or preferably fix the COPY command to reference a file that exists in your context, e.g.:

    COPY index.html /usr/share/nginx/html/
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search