Missing documentation about HOME folder in Docker Actions

Hi GH community,

I’d like to ask if you agree that in this page about custom Docker Actions there seems to be missing that HOME env var is changed when the action is ran.

docker run -e HOME ...

This will affect entrypoint scripts that rely on ~/ or $HOME.

ssh-keyscan -t rsa -H github.com >> ~/.ssh/known_hosts

I spent the weekend pulling my hair because of this little detail :slight_smile:

1 Like

@mxcoder,

When you start and run a docker container, there are parts of the space on the host machine will be used as the filesystem of the container. In the container, the $HOME point to the home in the filesystem of the container instead of the host machine.

If you want to share data between the container and the host machine, you can set some volumes.

To view more details, you can see “Manage data in Docker”.

Hi @brightran

Yeah, I think I kind of understand why they do it, but IMO its something worth mentioning explicitly in the documentation about writing Docker based actions.

Maybe something like:

Entrypoint scripts should not blindly relay on $HOME/ or ~/ because the image will be run with a modified HOME env variable for (reasons)

This was tricky to catch specially if you need to play around things like ~/.ssh/ directories. Using docker run -e HOME will create a disconnection between the running user and its ~/.ssh/ files and configurations.

Entrypoint scripts should not blindly relay on $HOME/ or ~/ because the image will be run with a modified HOME env variable for (reasons)

I feel that this is beside the point. Stuff in a Docker container runs in isolation, similar to a virtual machine. That’s Docker lesson 101. It’s worth mentioning in the docs, so that people new to this have an easier time, but the explanation shouldn’t be based on the wrong assumption that the host file system is equal to the Docker container file system. It should briefly say that a container is an isolated environment, and if you want to have access to anything from the host system then you need to mount it into the container.

1 Like