Docker Community Forums

Share and learn in the Docker community.

Docker can't load config file, but container works fine

I’m using docker-machine with generic driver to deploy containers on an existing remote host. But when I switch to the remote host and try to run a container, this happens:

$ docker-machine create --driver generic --generic-ip-address=$REMOTEIP \
--generic-ssh-key ~/.ssh/id_rsa --generic-ssh-user $REMOTEUSER vm
[works fine]

$ eval $(docker-machine env vm) #switch to remote host
[works fine]

$ docker run -it busybox sh
WARNING: Error loading config file:/home/user/.docker/config.json - open /home/user/.docker/config.json: permission denied
[Even with the warning, runs fine]

The container runs fine anyway, but I want to solve that warning message.

Given that user doesn’t exist in the remote host, I guess that this file doesn’t exist. But …

  1. why does the engine search for it in the first place? shouldn’t it search for the config.json of $REMOTEUSER instead of that?

  2. and why the container runs properly on the remote host anyway?

Turns out docker is not searching for that file in the remote host but in the local host. Turns out that file exists and it’s owned by root.

$ ls -lsa ~/.docker/config.json 4 -rw------- 1 root root
95 dic 29 15:29 /home/user/.docker/config.json

That’s why it says permission denied.

A simple chown fixes the issue:

$ sudo chown user:user /home/user/.docker -R