You should always run docker build command from the directory where your webapp.war file is present.
. in ./webapp.war tells the docker build command to look for the file in the current directory.
Without webapp.war in the current dir.
docker build -f Dockerfile .
Output :
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
I created a webapp.war file in the current directory :
touch webapp.war
Now ran the docker build command :
docker build -f Dockerfile .
Output :
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
It built fine.