tomcat - How can I automatically run a docker container on/after image build? -


i'm new docker sorry if miss obvious

my plan dockerfile.

  1. pull tomcat:7.0
  2. start server
  3. download helper files , unzip them.
  4. download required war file , rename root.war.

i've managed running these commands manually.

docker run -it --rm -p 8888:8080 tomcat:8.0

then manually doing wget's , renaming, although done in docker file.

this i've managed far.

from tomcat:7.0  run /bin/bash -c "cd /usr/local/tomcat/webapps"   run /bin/bash -c "wget -o files.zip https://***" run /bin/bash -c "unzip files.zip"  run /bin/bash -c "rm -r root" run /bin/bash -c "wget -o root.war https://***" 

although not sure how run docker line earlier docker run -it --rm -p 8888:8080 tomcat:8.0

i've taken line official tomcat online here. noticed mentioned run default tomcat server (cmd ["catalina.sh", "run"]): have no idea how implement this.

what dockerfile does, create image not container.

when docker build -t <tagname> . , see result (tagged) if run docker images.

you can run image create container.

you can specify cmd run (by default) in dockerfile. (i think)

cmd [ "catalina.sh", "run" ]  

so:

docker build -t my_tomcat_app . docker run -d -p 8888:8080 --name my_tomcat_container my_tomcat_app 

this create container image, , run whatever cmd said. can poke around inside docker exec

docker exec -it my_tomcat_container bash 

but it'll stay running (because of -d flag) , show in docker ps.


Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -