Home > Enterprise >  Docker compose: Change volume mapping from a docker volume to a folder on the server
Docker compose: Change volume mapping from a docker volume to a folder on the server

Time:02-24

I have an instance of Jira running on an Ubuntu server with docker-compose.

I initially set it up by mapping the jira installation folder to a docker volume called jiravolume.

volumes:
 - jiravolume:/var/atlassian/application-data/jira

To have easier access to the data, I would like to have this folder directly inside a folder on the Ubuntu server.

First of all, is there any difference in terms of performance/security?

If none, what are the steps to achieve this?

Let's assume that I want the data in a folder with a path (relative to the docker-compose file) like this: ./persist/jira/installfolder Do I need to create the folder structure on the server first and then change the docker-compose to become:

volumes:
 - ./persist/jira/installfolder:/var/atlassian/application-data/jira

Is the data now automatically copied in the new folder or is it still in the old volume and so now jira is pointing to an empty folder?

Thank you so much

CodePudding user response:

No that will not work, docker will create a nice empty new folder for you.

If on linux, your volume should be stored here: /var/lib/docker/volumes

You could:

  1. create ./persist/jira/installfolder and
  2. copy the files over. Then
  3. you'll have to change permissions on your files. And
  4. Make the changes you proposed in docker-compose.yaml
  5. Restart docker-compose. (docker-compose down && docker-compose up should be enough)

Mind you: If that path ./persist/jira/installfolder is inside your docker context you might have to check your Dockerfile to see about any COPY or ADD statements. If for example you have a COPY . . somewhere, you run the risk of copying your volume into your image if you ever rebuild it. In that case: either change those statements, or add your path to .dockerignore

  • Related