ReynierPM ReynierPM - 1 year ago 101
Linux Question

Docker volume option create folder as "root" user

I am logged in in my PC (Fedora 24) as

. I have setup Docker for being able to run through this user, so I am running a container as follow:

$ docker run -d \
-it \
-e HOST_IP= \
-p 80:80 \
-v ~/var/www:/var/www \
--name php55-dev reypm/php55-dev

Notice the
sign meaning I am running the command as a non root user (which uses
). The command above creates the following directory:
but owner is set to
I believe this is because
run as
user behind scenes.

Having this setup I am not able to create a file under
because the owner is
so ...

What is the right way to deal with this? I have read this and this but is not so helpful.

Any help?

Answer Source

As discussioned here, this is an expected behavior of docker. You can create the target volume directory before running docker command:

chown $(whoami) /path/to/your/dir
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download