0

How do I execute a SSHFS Mount to mount a volume on a different server into my docker image / docker container ?

The docker container contains a simple NodeJS web server. This web-page displays pictures. I have to get those image-files from a different server with different IP.

So far I had this without a docker container. For this I had a CronJob which executes the SSHFS mount to my system. Then the NodeJS server had the files and I was able to display the pictures.

Now I have to do the same with a docker container. I'd like to have the volume inside the container but I don't think that it works with the docker run -v /path/ [...] because this would require that I have the files on the host that the container lies in.

Is it possible to add the SSHFS mount into the docker run command or the Dockerfile ? Are there any other alternatives ?

~ cat Dockerfile
FROM node:alpine

RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app

COPY package.json /usr/src/app/
RUN npm install

COPY . /usr/src/app

EXPOSE 80
CMD [ "npm", "start" ]
Wulthan
  • 417
  • 2
  • 6
  • 19
  • you can mount an external folder when you do the `docker run` like `docker run -v /local/files:/docker/container/files ... ` – Edwin Jul 05 '17 at 09:44
  • @Edwin I noticed that but I should add that the files that I need are not on the local system, they are on a different server – Wulthan Jul 05 '17 at 09:48
  • make a script to download them on the local system and then mount with `-v` or download them directly on image – Edwin Jul 05 '17 at 09:49
  • @Edwin The files are images that can change at any time so I need something like a mount so they are up-to-date – Wulthan Jul 05 '17 at 09:51
  • maybe will help if you can better describe the case – Edwin Jul 05 '17 at 10:00
  • @Edwin I clarified it. – Wulthan Jul 06 '17 at 07:26
  • did you try to install sshfs on the image and then mount the external folder? `RUN apt-get install sshfs` and then add either a sh script to start you the npm and mount the folder or just make an script to mount that and start after the run (from docker container or from outside with docker exec) – Edwin Jul 06 '17 at 07:50

0 Answers0