The easiest way is to use the volume parameter (-v
) with docker run
to have the webapps
directory and tomcat-users.xml
file stay on the host filesystem, not on the container one.
For instance, on a Linux host:
- create a file named
/tmp/tomcat-users.xml
with the correct content for your needs;
- Then, create an empty directory named
/tmp/webapps
.
Now, run your container this way:
docker run -it --rm -p 8888:8080 -v /tmp/tomcat-users.xml:/usr/local/tomcat/conf/tomcat-users.xml:ro -v /tmp/webapps:/usr/local/tomcat/webapps:rw tomcat:7
Then, since the container is started in foreground, connect to another shell (another window) and copy your war file into /tmp/webapps.
It will be automatically deployed.
For instance, on a Windows host:
- create a file named
c:\tmp\tomcat-users.xml
with the correct content for your needs;
- Then, create an empty directory named
c:\tmp\webapps
.
Now, run your container this way:
docker run -it --rm -p 8888:8080 -v //c/tmp/tomcat-users.xml:/usr/local/tomcat/conf/tomcat-users.xml:ro -v //c/tmp/webapps:/usr/local/tomcat/webapps:rw tomcat:7
Then copy your war file into c:\tmp\webapps
. It will be automatically deployed.