Docker Community Forums

Share and learn in the Docker community.

War file not deploying


#1

I noticed that using docker-compose, my services.war file is no longer deploying to Tomcat.

The war file size is 64 MB, but I don’t see any errors in the Tomcat log.

My docker-compose.yml file is:

version: ‘3’
services:
app:
build:
context: .
dockerfile: Dockerfile
ports:
- “8089:8080”
volumes:
- /Users/mike/Library/apache-tomcat-9.0.7/conf/tomcat-users.xml:/usr/local/tomcat/conf/tomcat-users.xml
depends_on:
- db
db:
image: mysql:5.7
container_name: test-mysql-docker
ports:
- 3307:3306
volumes:
- ./ZipCodeLookup.sql:/docker-entrypoint-initdb.d/ZipCodeLookup.sql
environment:
MYSQL_ROOT_PASSWORD: “thepass”

==

And, the Dockerfile that works, called by the above, is:

FROM tomcat:8.0.20-jre8

ADD services.war /usr/local/tomcat/webapps/


Suggestions what could be wrong?

Thanks!

  • mike

(Ovelindstrom) #2

This is a tricky little thing… :smiley:

There is a small difference in the Docker file keywords ADD and COPY. What can happen if you add something into the docker image is that it might ignore it on the next build, because it is already there.

When working with this typs of files, I normally uses COPY instead. Like this

COPY /1.0-SNAPSHOT/my-app-1.0-SNAPSHOT.war /usr/local/tomcat/webapps/myapp.war

And make sure that your Tomcat has autodeploy configured.

Another way to do it is to not build a specific tomcat for each application but mount the war-file into a generic tomcat like this:

volumes:
    - ./conf/tomcat-users.xml:/usr/local/tomcat/conf/tomcat-users.xml
    - ./1.0-SNAPSHOT/my-app-1.0-SNAPSHOT.war /usr/local/tomcat/webapps/myapp.war

#3

Thanks very much. Good info.

I appear to be confused about something since, although I did a “docker compose down”, the problem went away when I removed all containers and images and did a “docker-compose up”.


(Ovelindstrom) #4

docker-compose down is expected to take down all the containers, networks, images, and volumes but I have noticed that it sometimes does not remove the images. I use the docker-compose build and docker-compose restart commands.

And… I like to use the volume mount instead of rebuilding. Or, I have a Make script that does build the Docker Image and then run the docker-compose-commands needed.


(Martin Terp) #5

“docker-compose down” itself dosnt remove images or volumes, you need extra params for that


#6

Thanks very much. That is helpful. :slight_smile:


#7

I appreciate your reply. I’ll add those options from now on.


(Ovelindstrom) #8

Great update. I hadn’t noticed the change.