[ 
https://issues.apache.org/jira/browse/MESOS-6340?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16414880#comment-16414880
 ] 

Qian Zhang edited comment on MESOS-6340 at 4/10/18 2:10 AM:
------------------------------------------------------------

I found Docker (actually it is {{runc}} internally) will always set {{HOME}} 
env var when launching a container:
 
[https://github.com/opencontainers/runc/blob/master/libcontainer/init_linux.go#L319:L324]
 Its logic is if user does not set {{HOME}} explicitly, get user’s home 
directory from /etc/passwd and set {{HOME}} to it, if user's home directory 
cannot be found in /etc/passwd (e.g., run a container with {{-u}} option to 
specify a uid which does not exist in /etc/passwd in the container image), set 
{{HOME}} to {{/}}.

So user may see different behaviors when launching a container via Mesos 
containerizer and Docker containerizer from the same Docker image, i.e., the 
former will not have {{HOME}} set but the later will have, that could be a 
problem, it might be a burden for customers to move from Docker containerizer 
to UCR.


was (Author: qianzhang):
I found Docker (actually it is {{runc}} internally) will always set {{HOME}} 
env var when launching a container:
https://github.com/opencontainers/runc/blob/master/libcontainer/init_linux.go#L319:L324
Its logic is if user does not set {{HOME}} explicitly, get user’s home 
directory from /etc/passwd and set {{HOME}} to it.

So user may see different behaviors when launching a container via Mesos 
containerizer and Docker containerizer from the same Docker image, i.e., the 
former will not have {{HOME}} set but the later will have, that could be a 
problem, it might be a burden for customers to move from Docker containerizer 
to UCR.

> Set HOME for Mesos tasks
> ------------------------
>
>                 Key: MESOS-6340
>                 URL: https://issues.apache.org/jira/browse/MESOS-6340
>             Project: Mesos
>          Issue Type: Bug
>          Components: agent, containerization
>            Reporter: Cody Maloney
>            Priority: Major
>              Labels: containerizer
>
> Quite a few programs assume {{$HOME}} points to a user-editable data file 
> directory.
> One example is PYTHON, which tries to look up $HOME to find user-installed 
> pacakges, and if that fails it tries to look up the user in the passwd 
> database which often goes badly (The container is running under the `nobody` 
> user):
> {code}
>     if i == 1:
>         if 'HOME' not in os.environ:
>             import pwd
>             userhome = pwd.getpwuid(os.getuid()).pw_dir
>         else:
>             userhome = os.environ['HOME']
> {code}
> Just setting HOME by default to WORK_DIR would enable more software to work 
> correctly out of the box. Software which needs to specialize / change it (or 
> schedulers with specific preferences), should still be able to set it 
> arbitrarily and anything a scheduler explicitly sets should overwrite the 
> default value of $WORK_DIR



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to