Search code examples
linuxdockeruser-accounts

Error running docker as a system user without home directory /dev/null: not a directory


I am trying to run docker commands as a system user without home directory.

For Ex.

sudo -u mysystemuser docker login -u user -p password

However I keep getting errors like

WARNING: Error loading config file:/dev/null/.docker/config.json - stat /dev/null/.docker/config.jso
n: not a directory
Error saving credentials: mkdir /dev/null: not a directory

Is their a way I can specify a directory for docker daemon? I have tried --graph and -g options to point at /tmp folder but it has not worked.


Solution

  • You need to pass --config /path/to/dir in the beginning of your docker command line (before the run, build, or other command you have docker perform). See the cli documentation for more details: https://docs.docker.com/engine/reference/commandline/cli/