Skip to content

Instantly share code, notes, and snippets.

@garthk
Last active August 21, 2022 04:26
Show Gist options
  • Save garthk/349204c9454e7bb9baa7 to your computer and use it in GitHub Desktop.
Save garthk/349204c9454e7bb9baa7 to your computer and use it in GitHub Desktop.
Fixing Docker on QNAP
$ export DOCKER_HOST=tcp://fnord.local:2376 DOCKER_TLS_VERIFY=1
$ docker ps
An error occurred trying to connect: Get https://fnord.local:2376/v1.21/containers/json: x509: certificate is valid for fnord, 192.168.23.23 , localhost, not fnord.local
$ ssh admin@fnord.local
# /sbin/setcfg global realm local -f /etc/config/smb.conf
# /etc/init.d/network.sh restart
# hostname -f
fnord.local
# cd $(dirname $(readlink /etc/init.d/container-station.sh))
# /etc/init.d/container-station.sh stop
# rm etc/docker/tls/*
# /etc/init.d/container-station.sh start
# cat etc/docker/tls/hostnames
fnord,192.168.23.23 , localhost
# echo AARGH

Hand-edit script/gen-docker-certs.sh so it sets:

CERTHOSTNAMES="$(hostname -f),$(hostname -s),$(hostname -i)"

Then repeat a few steps:

# /etc/init.d/container-station.sh stop
# rm etc/docker/tls/*
# /etc/init.d/container-station.sh start
# cat etc/docker/tls/hostnames
fnord.local,fnord,192.168.23.23 , localhost,127.0.0.1

Better. Not sure where the 127.0.0.1 came from, but better.

@garthk
Copy link
Author

garthk commented Nov 5, 2015

That, copying the new ca.pem, cert.pem, and key.pem, and these environment variables did the trick, ish:

DOCKER_HOST=tcp://fnord.local:2376
DOCKER_TLS_VERIFY=1
DOCKER_CERT_PATH=~/.docker/fnord/certs

The problem now being the version lag:

$ docker ps
Error response from daemon: client and server don't have same version (client : 1.21, server: 1.18)

@zallison
Copy link

Thank you so much for this, this fixed everything.

@lulukas86
Copy link

+1 thanks for this, helped a lot! Got the same problem because of the use of a nat'ed IP address. Just added the nat'ed IP to $CERTHOSTNAMES

@ancashoria
Copy link

What does this do exactly?

@rofl
Copy link

rofl commented Sep 1, 2019

Thank you, 4 years later, still a trap...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment