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 publish an ASP.NET Core application in a Docker container?
  • Docker-compose: always receive Cannot locate specified Dockerfile
  • Limit memory on a docker container doesn't work
  • Where to keep dependencies (large files or directory structures) for use with Docker/Docker-Compose?
  • Speeding up docker build for golang vendoring
  • Pycharm 2017.1 EAP Python Console and Remote Docker Interpreter not working together
  •     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.

  • How to gain bash access to a docker container after its ran
  • Remote Node.js typescript debugging in WebStorm
  • ParaView in Docker with OpenGL support
  • How to interact with docker swarm to change the strategy in scheduler
  • Is it possible to perform Docker-call from a container into the host?
  • Connection Refused Error 61: Scrapy+splash Docker
  • 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.