Milad
Milad

Reputation: 5510

How to create a docker volume from a recipe?

I have a bash script recipe that creates large assets. I'd like to create them once and use them in different docker containers. I'm assuming the best way to handle this is to create a docker volume containing these assets but how do I do that? I prefer not copy files into the volume directly from the host as that's not really version controlled. Can this be achieved using dockerfiles?

Upvotes: 0

Views: 91

Answers (2)

Milad
Milad

Reputation: 5510

I think this answers my question. In summary:

  1. Create a Dockerfile that's along these lines:
FROM ubuntu
RUN mkdir /dataset
RUN ***populate /dataset***
VOLUME /dataset
  1. Build the docker image
  2. Build a container from that image
  3. Mount /dataset in any container you need using --volumes-from option

Upvotes: 0

lonelyelk
lonelyelk

Reputation: 578

You can use docker-compose.yml to set up a volume sharing between containers. And you can declare mount points in respective Dockerfiles using VOLUME instruction. More in detail explanation is in Volumes Documentation

Upvotes: 1

Related Questions