Docker: Dockerfile COPY — not a directory

Автор: | 11/10/2015
 

docker_lxcИмеется Dockerfile для билда образа Docker с Java-приложением:

FROM java:8
MAINTAINER User "user@domain.com"
COPY eod-report-0.0.1-SNAPSHOT.jar /opt
ENTRYPOINT ["/usr/bin/java", "-jar"]
CMD ["/eod-report-0.0.1-SNAPSHOT.jar"]

Во время билда на Go CD агенте — сборка падает с сообщением:

17:19:12.677 Sending build context to Docker daemon
17:19:12.719 Step 0 : FROM java:8
17:19:12.720  ---> c1ccce98b537
17:19:12.720 Step 1 : MAINTAINER User "user@domain.com"
17:19:12.870  ---> Using cache
17:19:12.870  ---> 54df967fb41b
17:19:12.870 Step 2 : COPY eod-report-0.0.1-SNAPSHOT.jar /opt
17:19:13.511 2015/11/09 17:19:13 stat /var/lib/docker/aufs/mnt/98f6c61bad68494918d738e6f9f44598c95ac8b385f63841d705612187c4d085/opt/eod-report-0.0.1-SNAPSHOT.jar: not a directory
17:19:13.624 [go] Current job status: failed.

Проблема вызвана тем, что путь <dest> в COPY указан без закрывающего слеша — /opt:

...
COPY eod-report-0.0.1-SNAPSHOT.jar /opt
...

В результате — Docker-демон считает <dest> не каталогом — а файлом.

Редактируем:

...
COPY eod-report-0.0.1-SNAPSHOT.jar /opt/
...

Готово:

...
18:01:16.690
18:01:16.690 Sending build context to Docker daemon
18:01:16.731 Step 0 : FROM java:8
18:01:16.732  ---> c1ccce98b537
18:01:16.732 Step 1 : MAINTAINER User "user@domain.com"
18:01:16.897  ---> Using cache
18:01:16.897  ---> 54df967fb41b
18:01:16.898 Step 2 : COPY eod-report-0.0.1-SNAPSHOT.jar /opt/
18:01:17.754  ---> 1b165fab2bb4
18:01:17.778 Removing intermediate container cf6d5ef54b26
18:01:17.779 Step 3 : ENTRYPOINT /usr/bin/java -jar
18:01:18.004  ---> Running in c22011fb88ae
18:01:18.070  ---> 0ce36b80ed68
18:01:18.078 Removing intermediate container c22011fb88ae
18:01:18.079 Step 4 : CMD /eod-report-0.0.1-SNAPSHOT.jar
18:01:18.301  ---> Running in a9a8019f1d6d
18:01:18.368  ---> 8d88c80e4a53
18:01:18.377 Removing intermediate container a9a8019f1d6d
18:01:18.378 Successfully built 8d88c80e4a53
18:01:18.410 [go] Current job status: passed.