I don't have /home/abc1 on my host (host name: mzhao).
Then I did this:
[mzhao@mzhao ~]$ docker run -it --user nobody -v home/abc1:/home/abc1 centos
bash-4.2$ id
uid=99(nobody) gid=99(nobody) groups=99(nobody)
On my host (mzhao), if I take a look of /home:
[mzhao@mzhao home]$ ls -l |grep abc1
drwxr-xr-x 2 root root 4096 Apr 2 21:26 abc1/
Is there a way to create /home/abc1 under another user on my host?
I am aware of docker user guide mentioned this:
auto-creation of the host path has been deprecated.
But I am just curious. This could happen just because the path does not exist on the host when user "docker command" and specify that directory as a volume.
Per Dockerfile reference guide, you can specify a user in your Dockerfile:
USER USER daemon The USER instruction sets the user name or UID to use when running the image and for any RUN, CMD and ENTRYPOINT instructions that follow it in the Dockerfile.
Refer to the following link for the reference found here.
So, for example, you can do something like this:
FROM foo
MAINTAINER bar
USER nobody
COPY file /to/point/b
RUN command
ENTRYPOINT["command"]
CMD["command params"]