How to update war files in a docker tomcat container

I’ve started looking through docs and beginning to understand docker. Created an image using the official tomcat:7-jre7 image and stuck a war in the appropriate place and it starts/stops fine.

My file for reference is :

  • How do I mount a host directory as a volume in docker compose
  • Script run inside docker container reporting significantly higher memory than outside
  • Docker with cloudflare
  • Docker-compose internal communication using endpoints
  • How to downloaded from remote location and execute script on container start Docker?
  • How to make docker service start on my system reboot automatically?
  •     FROM tomcat:7-jre7
        MAINTAINER: me, me@hotmail.com 
        ADD app.war /usr/local/tomcat/webapps
        EXPOSE 8080
        CMD ["catalina.sh", "run"]
    

    Now that thats all good I have two questions:

    1. In the event of something bad, can I ssh in and look at log files or something?
    2. How does one update the war file? Is there some way to ssh / scp a new file in?

    So far I’ve tried starting the original image by doing:

       docker run -t <_id> /bin/bash 
    

    and then doing an attach like below from a different session, but that didnt’r do much – all I saw was a black screen.

       docker attach <running_container_id> 
    

    Another way (untested) I thought of was to share the file from the host – hopefully updating the war file will trigger tomcat to redeploy the war file? Has anyone attempted this?

    Is there a nicer simpler way to do this?

    Thanks for any input, appreciate it.

  • Why Can I not resolve docker.io and other hosts behind proxy from within Vagrant VM
  • Easy, straightforward, robust way to make host port available to Docker container?
  • Migrations are pending. To resolve this issue, run: bin/rake db:migrate RAILS_ENV=development, works localy tho
  • Docker: access to VPN domain from docker
  • How to access docker's tomcat logs and config file, not the local one but server logs?
  • How to copy a file from container to host using copy in docker-py
  • One Solution collect form web for “How to update war files in a docker tomcat container”

    You have several options, depending on what you want to do. The easiest option is to simply have the folder for your built war file also contain the Dockerfile you have above. Then, whenever the war file is updated, kick off a docker build and docker run. This could be automated easily with fig as well, with something like:

    tomcat:
        build: ./war
    

    Now just run fig up whenever the war file changes and your new container will get built from the Dockerfile in the war folder and ran.

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.