Skip to content

Instantly share code, notes, and snippets.

@danehammer
Created November 26, 2015 03:58
Show Gist options
  • Save danehammer/c62442f98f5860441bd8 to your computer and use it in GitHub Desktop.
Save danehammer/c62442f98f5860441bd8 to your computer and use it in GitHub Desktop.
example volume permissions problem
FROM ubuntu:14.04
RUN mkdir /vol
RUN useradd elasticsearch
RUN echo "elasticsearch:elasticsearch" | chpasswd
RUN chown elasticsearch:elasticsearch /vol
VOLUME /vol
USER elasticsearch
CMD bash
@danehammer
Copy link
Author

Build an image from this file with:

docker build -t="volume_test" .

Create a directory locally with permissions set to 600 (assuming you're not elasticsearch on your local host):

mkdir ~/vol
chmod 600 ~/vol

Run the volume_test image, mounting ~/vol as the /vol volume:

docker run -it -v ~/vol:/vol volume_test

Then try to do anything to /vol:

elasticsearch@volume_test:/$ cd /vol
bash: cd: /vol: Permission denied

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment