Elsayed
Elsayed

Reputation: 3012

Passing deployment files into docker container during starting

I want to deploy .war application into docker container ,

I tried to build docker Image containing tomcat server and it's deployment

files such as wars and jars,

 #set the base image 
    FROM  my-base-image
    # author
    MAINTAINER elsayed
    # extra metadata  
    LABEL version="1.0" 
    LABEL description="The First Image for tomcat"

    #add server-files

    RUN mkdir -p /root/apache-tomcat-8.0.24
    COPY apache-tomcat-8.0.24 /root/apache-tomcat-8.0.24

    add receiver.war  /root/apache-tomcat-8.0.24/webapps
    add common.jar /root/apache-tomcat-8.0.24/mule-libs/user/myapp
    add model.jar /root/apache-tomcat-8.0.24/mule-libs/user/myapp
    add wsdl.jar /root/apache-tomcat-8.0.24/mule-libs/user/myapp
    add service.jar /root/apache-tomcat-8.0.24/mule-libs/user/myapp
    add StatusCodes.jar /root/apache-tomcat-8.0.24/mule-libs/user/myapp


    RUN echo '/root/apache-tomcat-8.0.24/bin/catalina.sh run -Xms256m -Xmx1G -XX:MaxPermSize=256m -Dmule.verbose.exceptions=true -Djava.net.preferIPv4Stack=true -Dlog4j.configuration=file:/root/elsayed/server/logging/tomcat/log4j.properties -Dlog4j.debug=true -Dvericash.home=/root/elsayed -Djboss.ejb.client.properties.file.path=/root/jboss-ejb-client.properties' 
  >> /root/apache-tomcat-8.0.24/bin/start.sh

    EXPOSE 9191

    CMD ["/bin/bash", "/root/apache-tomcat-8.0.24/bin/start.sh"] 

I 'am using that in development , I'am continuously edit and deploy the application many times so I have to build the docker image again ,

Is there a way to pass the .war and jars into docker container while running it without rebuilding the image again ?

Upvotes: 1

Views: 711

Answers (1)

OscarAkaElvis
OscarAkaElvis

Reputation: 5724

Yeah, you can map a volume on docker run command adding -v /your/host/dir:/your/dir/inside/container. On that way you'll have one directory on your host which is inside of your container.

Then you can copy the needed files to that directory to deploy it on container. Then, if you need to run a command inside the container (for example a service restart or something) you can use docker exec <containerId> <yourCommand>.

Upvotes: 1

Related Questions