Docker COPY command does not copy

  copy, docker, postgresql

I’ve read several same questions, but it still unclear to me why COPY command doesn’t work properly. Here is my example:
a.txt placed near Dockerfile which contains the following code

# syntax=docker/dockerfile

FROM postgres:11

WORKDIR /usr/lib/postgresql/11/lib
COPY a.txt .

that I ran docker build . and get the output

Sending build context to Docker daemon  3.584kB
Step 1/3 : FROM postgres:11
11: Pulling from library/postgres
aed007321795: Pull complete 
702c74af4354: Pull complete 
ef123e2ab09b: Pull complete 
c84418d8530c: Pull complete 
b579800618be: Pull complete 
6562ab9a134a: Pull complete 
1c9daa412a3b: Pull complete 
ef585939c140: Pull complete 
441afbb7b4bb: Pull complete 
c7aa402b2495: Pull complete 
3890ec9ba5d6: Pull complete 
6a4fce211dfc: Pull complete 
380c4b145ef6: Pull complete 
Digest: sha256:944f2e7c91c48e41153e5a20a27baaf251da425931e7e5e43dc46c5a961ddfe0
Status: Downloaded newer image for postgres:11
 ---> c136798ef3a3
Step 2/3 : WORKDIR /usr/lib/postgresql/11/lib
 ---> Running in 800e2be9eb49
Removing intermediate container 800e2be9eb49
 ---> 120f56733739
Step 3/3 : COPY a.txt a.txt
 ---> ea1fd6600166
Successfully built ea1fd6600166

To start container I use docker run -it -e POSTGRES_PASSWORD=postgres -p 5430:5432/tcp postgres:11. After attaching to the container a.txt doesn’t appear in the mentioned directory.

Source: Docker Questions

LEAVE A COMMENT