IBM Security QRadar SOAR

 View Only
  • 1.  Installing Local App in Dockerfile

    Posted Thu May 06, 2021 04:06 PM
    I am fairly new to Docker and working on learning it. One of the questions is if I wanted to include a zip file that Docker will unzip and deploy in the container during deployment, how would I go about putting that file in my app to ensure that it when it deploys it is added to my container.

    Thanks in advance!

    ------------------------------
    Nick Mumaw
    ------------------------------


  • 2.  RE: Installing Local App in Dockerfile

    Posted Fri May 07, 2021 07:01 AM
    Hi Nick,

    There there are a number of ways to copy files into a container after it starts running including the following:

    When starting the  container map a local file to container file.
    docker run -v <local_path_to_file>/<file>:/<container_path_to_file>/<file> <image_name_id>

    After container has started copy  a local file to container file path:
    docker cp <local_path_to_file>/<file> <container_name_or_id>:/<container_path_to_file>

    Does this help?

    Regards,

    ------------------------------
    JOHN PRENDERGAST
    ------------------------------



  • 3.  RE: Installing Local App in Dockerfile

    Posted Fri May 07, 2021 08:42 AM
    Hey John,

    I am not sure that helps as I was trying to do it in the DockerFile that creates the container. I was thinking if I did it in the docker file to be part of the container creation then I am able to add this to the AppHost so that the file deploys with the AppHost. My understanding is that if I change the container after it is already running, if it reboots, it resets it back to the original image. Plus I am not sure how I would go about getting the AppHost to run that command during the deployment.

    Basically I have a driver that I need to use to run part of my python script. I have that drive zipped up and in the zip folder of the app and was trying to write into the dockerfile the command to copy that file into the container, unzip it to the location I need it, and then set the environment variables to know where these drivers are. below is what I was trying, but it says it can't find the file.

    RUN unzip data/driver.zip -d /opt/
    ENV DRIVER_HOME /opt/driver/
    ENV DRIVER_LIB /opt/driver/lib/

    Hopefully this helps give context behind what I am doing.

    Thanks!

    ------------------------------
    Nick Mumaw
    ------------------------------



  • 4.  RE: Installing Local App in Dockerfile

    Posted Fri May 07, 2021 09:58 AM
    Hi Nick,

    Something like the following should work:

    Assuming you are in toplevel folder of your app and driver.zip is at data/driver.zip

    Add the following to the Dockerfile

    COPY data/driver.zip /tmp
    RUN unzip /tmp/driver.zip -d /opt/

    ------------------------------
    JOHN PRENDERGAST
    ------------------------------



  • 5.  RE: Installing Local App in Dockerfile

    Posted Fri May 07, 2021 10:15 AM
    If you wanted to do a bit of cleanup you could put this after the unzip command

    RUN rm /tmp/test.zip

    Regards

    ------------------------------
    JOHN PRENDERGAST
    ------------------------------



  • 6.  RE: Installing Local App in Dockerfile

    Posted Fri May 07, 2021 01:37 PM
    This works perfectly! Thanks for the help John!

    ------------------------------
    Nick Mumaw
    ------------------------------