My first idea was: Download tomcat, configure everything and then build an image.
BUT: After i learned how to use the -v (--volume) flag for adding some file via the docker command to an image i was wondering, wether creating a new image with only the additional files on top of standard tomcat docker image.
So first step is to take a look at all local images:
# docker imagesI can use tomcat:latest. (if it is not there just pull it: docker pull tomcat)
REPOSITORY TAG IMAGE ID CREATED SIZE
558MB
friendlyhello latest 976ee2bb47bf 3 days ago 148MB
tomcat latest 11df4b40749f 8 days ago 558MB
Next step is to create a directory and add all the directories which you want to override.
For my example:
mkdir conftomcatInto the bin directory i put all the files from the tomcat standard container:
cd conftomcat
mkdir bin
# ls bin
bootstrap.jar catalina-tasks.xml commons-daemon-native.tar.gz daemon.sh setclasspath.sh startup.sh tool-wrapper.sh
catalina.sh commons-daemon.jar configtest.sh digest.sh shutdown.sh tomcat-juli.jar version.sh
Inside the catalina.sh i added -Xmx384M.
In conftomcat i created the following Dockerfile:
FROM tomcat:latestAnd as you can see i added my index.jsp which is inside status (s. this posting).
WORKDIR /usr/local/tomcat/bin
ADD status /usr/local/tomcat/webapps/mystatus
ADD bin /usr/local/tomcat/bin
ENTRYPOINT [ "/usr/local/tomcat/bin/catalina.sh" ]
CMD [ "run"]
Ok. Let's see, if my plan works:
#docker build -t mytomcat .
ending build context to Docker daemon 375.8kBand then start:
Step 1/6 : FROM tomcat:latest
---> 11df4b40749f
Step 2/6 : WORKDIR /usr/local/tomcat/bin
---> Using cache
---> 5696a9ab99cb
Step 3/6 : ADD status /usr/local/tomcat/webapps/mystatus
---> 1bceea5af515
Step 4/6 : ADD bin /usr/local/tomcat/bin
---> e8d3a386a7f0
Step 5/6 : ENTRYPOINT [ "/usr/local/tomcat/bin/catalina.sh" ]
---> Running in a04038032bb7
Removing intermediate container a04038032bb7
---> 4c8fda05df18
Step 6/6 : CMD [ "run"]
---> Running in cce378648e7a
Removing intermediate container cce378648e7a
---> 72ecfe2aa4a7
Successfully built 72ecfe2aa4a7
Successfully tagged mytomcat:latest
docker run -p 4001:8080 mytomcatLet's check the memory settings:
$ ps aux|grep javaYes - changed to 384M.
root 2313 20.7 8.0 2418472 81236 ? Ssl 19:51 0:02 /docker-java-home/jre/bin/java -Djava.util.logging.config.file=/usr/local/tomcat/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Xmx394M -Djdk.tls.ephemeralDHKeySize=2048 -Djava.protocol.handler.pkgs=org.apache.catalina.webresources -classpath /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar -Dcatalina.base=/usr/local/tomcat -Dcatalina.home=/usr/local/tomcat -Djava.io.tmpdir=/usr/local/tomcat/temp org.apache.catalina.startup.Bootstrap start
And check the jsp:
Yippie!
As you can see, i have the standard tomcat running with an override inside the configuration to 384M. So it should be easy to add certificates, WARs, ... to such a standard container.
Related posts:
- Docker on Ubuntu
- Running through a tutorial / investigating the processes
- Creating a small linux for my docker cluster (Alpine Linux)
- How to build a docker swarm
- Creating a minimal webserver container and deploying it to docker swarm
- Setting up a tomcat with docker
- Running a swarm with multiple managers
- Mysql inside a docker container - persistency with docker volumes
- How to change the configuration of a standard docker container(e.g. changing tomcats memory settings)
No comments:
Post a Comment