docker / machine

Machine management for a container-centric world
https://docs.docker.com/machine/
Apache License 2.0
6.63k stars 1.97k forks source link

docker-machine build will only copy .zip files #4793

Open altano opened 4 years ago

altano commented 4 years ago

Dockerfile:

FROM nginx:alpine
COPY logo.png /usr/share/nginx/html/

results in:

$ docker-compose build app
Building app
Step 1/3 : FROM nginx:alpine
 ---> 377c0837328f
Step 2/3 : COPY logo.png /usr/share/nginx/html/
ERROR: Service 'app' failed to build: COPY failed: stat /var/lib/docker/tmp/docker-builder483187277/logo.png: no such file or directory

While Dockerfile:

FROM nginx:alpine
COPY app.zip /usr/share/nginx/html/

builds successfully.

git-blame commented 4 years ago

This seems strange. My nginx Dockerfile copies all sorts of files include nginx.conf, entrypoint.sh, and other files. Are you sure you're not missing file logo.png at app/logo.png

altano commented 4 years ago

I’m sure the image is present side-by-side with the zip file. Did you specify an “app” sub directory for a reason?

Can you try that exact Dockerfile I pasted with a PNG image? I’m curious if I’m imagining things :)

Lastly: are you using Docker Machine?

git-blame commented 4 years ago

I'm using docker-machine with aws. With docker-compose, I put each service in its own subdir along with its docker file and associated files. And your example works for me.

docker-compose build app
Building app
Step 1/2 : FROM nginx:alpine
alpine: Pulling from library/nginx
cbdbe7a5bc2a: Pull complete
c554c602ff32: Pull complete
Digest: sha256:763e7f0188e378fef0c761854552c70bbd817555dc4de029681a2e972e25e30e
Status: Downloaded newer image for nginx:alpine
 ---> 89ec9da68213
Step 2/2 : COPY logo.png /usr/share/nginx/html/
 ---> 39d336b3e732

Successfully built 39d336b3e732
Successfully tagged demo_app:latest
cnguyen@stretch:~/work/docker/demo$ ls *
docker-compose.yml

app:
Dockerfile  logo.png
cnguyen@stretch:~/work/docker/demo$ cat docker-compose.yml
version: '3.3'

services:

  app:
    build:
      context: ./app
      dockerfile: Dockerfile
cnguyen@stretch:~/work/docker/demo$ cat app/Dockerfile
FROM nginx:alpine

COPY logo.png /usr/share/nginx/html/
docker-machine ssh awsdemo "sudo docker image ls demo_app"
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
demo_app            latest              39d336b3e732        8 minutes ago       19.9MB