Different home directory during Docker build in Do

2019-05-27 11:15发布

问题:

I have found a strange difference between building docker images in my Ubuntu 14.04 host machine and the Docker Hub automated builds.

This is my Dockerfile:

FROM buildpack-deps:wheezy-scm
RUN echo $HOME

This is the output in my machine:

 ---> 2afbec25f6f6
Step 1 : RUN echo $HOME
 ---> Running in 6074455e13c0
/
 ---> 0cb1b6141f93
Removing intermediate container 6074455e13c0
Successfully built 0cb1b6141f93

And this one comes from Docker hub:

---> 2afbec25f6f6
Step 1 : RUN echo $HOME
/root
---> 4c781d2d7d72
Successfully built 4c781d2d7d72

Note the different HOME directories: /root instead of /. Can anyone explain me what is happening?

This is my Docker version (I have installed the standarddocker.io Ubuntu package):

$ docker version
Client version: 1.0.1
Client API version: 1.12
Go version (client): go1.2.1
Git commit (client): 990021a
Server version: 1.0.1
Server API version: 1.12
Go version (server): go1.2.1
Git commit (server): 990021a

回答1:

Effectively there were a change in $HOME, and the changes were merged after Docker release v1.0. I have built the Dockerfile you provided and it shows me $HOME=/root (I use Docker v1.5.0). Check Docker Issue #2968 and related commits for additional details.