Docker에서 이미지를 빌드할 때 다음 오류가 발생합니다.
docker build -t demo .
산출:
Sending build context to Docker daemon 2.048kB
Step 1/3 : From tomcat:8
---> 8973f493aa0a
Step 2/3 : MAINTAINER "shweta"
---> Using cache
---> 4b846800a044
Step 3/3 : COPY ./webapp.war /usr/local/tomcat/webapps
실수:
COPY failed: stat /var/lib/docker/tmp/docker-builder389027616/webapp.war: no such file o r directory
도커 파일:
# Pull base image
From tomcat:8
# Maintainer
MAINTAINER "shweta"
# copy war file on to container
COPY ./webapp.war /usr/local/tomcat/webapps
답변1
docker build
항상 파일이 있는 디렉토리에서 명령을 실행 해야 합니다 webapp.war
.
.
in은 현재 디렉터리에서 파일을 찾도록 명령에 ./webapp.war
지시합니다 .docker build
webapp.war
현재 디렉터리에 없습니다 .
docker build -f Dockerfile .
산출:
Sending build context to Docker daemon 748kB
Step 1/3 : From tomcat:8
8: Pulling from library/tomcat
092586df9206: Pull complete
ef599477fae0: Pull complete
4530c6472b5d: Pull complete
d34d61487075: Pull complete
272f46008219: Pull complete
12ff6ccfe7a6: Pull complete
f26b99e1adb1: Pull complete
21bec9c8ea28: Pull complete
b8a32f28e27c: Pull complete
94fdd0ba0430: Pull complete
Digest: sha256:bb4ceffaf5aa2eba6c3ee0db46d863c8b23b263cb547dec0942e757598fd0c24
Status: Downloaded newer image for tomcat:8
---> 8973f493aa0a
Step 2/3 : MAINTAINER "shweta"
---> Running in f84d33a29144
Removing intermediate container f84d33a29144
---> d1823a301759
Step 3/3 : COPY ./webapp.war /usr/local/tomcat/webapps
COPY failed: stat /var/lib/docker/tmp/docker-builder241674033/webapp.war: no such file or directory
webapp.war
현재 디렉터리에 파일을 만들었습니다 .
touch webapp.war
이제 docker build
다음 명령을 실행하십시오.
docker build -f Dockerfile .
산출:
Sending build context to Docker daemon 749.1kB
Step 1/3 : From tomcat:8
---> 8973f493aa0a
Step 2/3 : MAINTAINER "shweta"
---> Using cache
---> d1823a301759
Step 3/3 : COPY ./webapp.war /usr/local/tomcat/webapps
---> 1f9c0af8b8d3
Successfully built 1f9c0af8b8d3
잘 지어졌습니다.