Bijesh CHandran
Bijesh CHandran

Reputation: 545

Docker volume mount issue to a mounted folder

We have mounted a folder in a Linux machine to our docker container application using (docker-compose) volumes: - /mnt/share:/mnt/share

The /mnt/share is a mounted folder in the machine(Not a real folder in the machine, its our file server). IF for some reason that mount is lost and then remounted again. The application running in the docker container is not having access to the mounted folder until the container is restarted.

Upvotes: 2

Views: 1675

Answers (3)

Daniel
Daniel

Reputation: 23

defining the mount propagation as ":shared" should fix this:

-v /autofs:/autofs:shared \

not sure about docker-compose - I don't really use that. but you can define a docker volume with mount propagation and put this into your DC file.

Upvotes: 0

Bijesh CHandran
Bijesh CHandran

Reputation: 545

The following solution helped me to continue. I wrote a script to check whether the folder exists. The script is then called a command in the docker-compose file.

   version:"3" 
  services:
   flowable-task-handler:
    build: flowable-task-handler  
    ports:
    - "8085:8085"
    command: bash -c "/wait_for_file_mount.sh /mnt/share/fileshares/ && java -jar /app.jar"

wait_for_file_mount.sh

#!/bin/sh
# Used to check whether the mount folder is ready for flowable to use
mountedfolder="$1"
until [  -d "$mountedfolder" ];
 do sleep 2;
  echo error "Mounted folder not found : $mountedfolder";
   done;

Its a spring boot application. I have removed the entrypoint in the DockerFile and application is started using the command in docker compose(java -jar /app.jar")

Upvotes: 1

Michael Dreher
Michael Dreher

Reputation: 1399

You might want to use to use a Volume Driver instead of bind-mounting a local filesystem. See Share data among machines

Without knowing more about your environment it is impossible to give a more detailed answer. It would be helpful to know if your container runs in a AWS data center or if you use nfsv3, nfsv4 or cifs for mounting.

Upvotes: 6

Related Questions