« Back to projectatomic.io
Ask Your Question

Where to place directories that are mounted inside containers?

asked 2016-02-01 14:29:15 +0000

Martin Šťastný gravatar image


I have decided not to use docker volumes and mount host directories or files to docker containers instead. My question is, where in Atomic Host is the right place to store this kind of data. Is there any specific place or I have to just create some directory inside /var?

Thank you in advance

edit retag flag offensive close merge delete


To clarify you'd like to use a Docker container as a Volume Container or you just want to store data locally in a running container?

nzwulfin ( 2016-02-04 15:52:53 +0000 )edit

I want to mount a host directory as a data volume. For example, if I execute "docker run -v /src/webapp:/opt/webapp image command", I am mounting host's /src/webapp to container's /opt/webapp. My question is, where is the right place in host's filesystem to place this /src/webapp directory.

Martin Šťastný ( 2016-02-04 22:38:50 +0000 )edit

2 answers

Sort by » oldest newest most voted

answered 2016-02-05 13:49:20 +0000

There's no particular place that is designated for those sorts of data stores. Since /var is the only writable location on an Atomic host, that would probably make the most sense to create a data store like that. The other option would be to start in /mnt but that's a symlink to /var/mnt anyhow.

For example, we create /var/src and every individual container gets a new directory under it. You'll want to make sure that you add the Z option to the volume in the docker run command. This will make sure to change the SELinux context on the /var/src/webapp directory but also add container specific labels to make sure that the other containers with volumes in /var/src can't read volumes they shouldn't.

sudo docker run --name some-nginx-Z -v /var/src/webapp:/usr/share/nginx/html:ro,Z -d nginx

edit flag offensive delete link more


Thank you very much. Just for completeness, if I use lower case "z" when mounting, more containers can mount this particular directory (eg. one with web server and one with FTP daemon) and when I use upper case "Z", this location is mounted exclusively.

Martin Šťastný ( 2016-02-05 17:42:34 +0000 )edit

That's absolutely right, sorry if my answer was confusing on the two options for SELinux labels

nzwulfin ( 2016-02-10 16:20:18 +0000 )edit

answered 2017-10-09 17:56:36 +0000

This facebook site is a very generate site. this hack fb site is very powerful and good site.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

[hide preview]


Asked: 2016-02-01 14:29:15 +0000

Seen: 140 times

Last updated: Oct 09