docker COPY copying files not in command list + ignoring .dockerignore

14 views Asked by At

I have simple docker directory with files as

$ ls -a
Dockerfile      
run.sh
app
.dockerignore
requirements.txt

where app is a folder containing python script.

My docker file looks like

FROM python:slim
WORKDIR /usr/src/myapp
COPY requirements.txt .
RUN pip install -r requirements.txt
COPY app .

Though I have not asked files in main directory to be copied (e.g. run.sh, Dockerfile), they are being copied

$ docker build -t tst .
$ docker run -it --rm -v "$PWD":/usr/src/myapp -w /usr/src/myapp tst bash
root@3231db38697a:/usr/src/myapp# ls -l
total 12
-rw-r--r-- 1 root root  518 Jun 19 11:00 Dockerfile
drwxr-xr-x 3 root root   96 Jun 19 11:00 app
-rw-r--r-- 1 root root   41 Jun 19 11:00 requirements.txt
-rw-r--r-- 1 root root 1867 Jun 19 11:00 run.sh

Also it does not seem to obey .dockerignore file. The .dockerignore file looks like

Dockerfile
.dockerignore
0

There are 0 answers