Search code examples
dockerdata-persistencedocker-volume

How can I make multiple copies of a docker container WITH configuration data?


I have a docker container with JIRA running in it. I have successfully configured JIRA with the correct workflows/fields. I now want to create a docker image of this so that I can propagate multiple copies of this configuration (yes, there's a licensing issue here, that's being addressed elsewhere).

I know to persist data I need to create a data container. But I don't want all my instances to use this same data volume - I just want my image to contain that data. But I'm not quite sure how to do this.

My thoughts are as follows:

  1. Create a data volume associated with my docker container.
  2. Configure everything
  3. Docker commit (?)
  4. On the new system create a new data volume
  5. Load the image created in step 3

Is this going to accomplish my goals?


Solution

  • From this link. The #id-old-container is the id that is returned when you run 'docker images'. However, make sure you dont 'exit' from the container. Instead detach from the container ( Ctrl-P then Ctrl-Q ), execute the following command, and then attach to the container.

    docker commit -m 'Commit Message' #id-old-container new-container-with-JIRA