1

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 Answers3

0

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
Alez
  • 1,913
  • 3
  • 18
  • 22
0

Make sure you're running over a linux based terminal (like WSL). It seems to be a "windows" issue.

Felipe Esteves
  • 363
  • 1
  • 10
0

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:\html\html\index.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/
BMitch
  • 231,797
  • 42
  • 475
  • 450