Docker でイメージをビルドすると、次のエラーが発生します。

Docker でイメージをビルドすると、次のエラーが発生します。

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

よく建てられました。

おすすめ記事