Docker Community Forums

Share and learn in the Docker community.

Extension to the --mount option


(Raldone01) #1

I hope this is the right place for my post.

Suppose I want to run the following container and make specific locations persistent.
docker run --detach --name test -v /srv/app/logs:/var/app/logs -v /srv/app/somedata:/var/app/data -v /srv/app/config:/etc/app/config busybox
As you can see I used bind mounts.
For ease of portability and backupability I would like to use a single volume called app.

The only way I to implement the above using volumes is:
docker volume create app_logs
docker volume create app_data
docker volume create app_config
docker run --detach --name test --mount 'type=volume,src=app_logs,dst=/var/app/logs' --mount 'type=volume,src=app_data,dst=/var/app/data' --mount 'type=volume,src=app_config,dst=/etc/app/config' busybox
(As far as know)

But I would have to use multiple volumes per container.

I would enjoy a mount syntax like that:
docker volume create app
docker run --detach --name test --mount 'type=volume,name=app,src=/srv/app/logs,dst=/var/app/logs' --mount 'type=volume,name=app,src=/srv/app/somedata,dst=/var/app/data' --mount 'type=volume,name=app,src=/srv/app/config,dst=/etc/app/config' busybox
(just an idea how this could be implemented)

If this functionality is already contained in docker, I failed to find it in docs. (Sorry and please guide me)