Skip to content

Instantly share code, notes, and snippets.

@deterralba
Created August 20, 2017 17:40
Show Gist options
  • Save deterralba/aa87fa28c1de199f9f4b4a953750c34b to your computer and use it in GitHub Desktop.
Save deterralba/aa87fa28c1de199f9f4b4a953750c34b to your computer and use it in GitHub Desktop.
Error with docker private registry and let's encrypt: read: connection reset by peer
# I set up a private registry with let's encrypt certificats with the following command:
$ docker run -p 443:5000 -p 5001:5001 --name registry -d --restart=always \
-e REGISTRY_HTTP_ADDR=0.0.0.0:5000 \
-e REGISTRY_HTTP_HOST=https://registry.mydomain.com \
-e REGISTRY_HTTP_TLS_LETSENCRYPT_CACHEFILE=/etc/docker/registry/letsencrypt.json \
-e REGISTRY_HTTP_TLS_LETSENCRYPT_EMAIL=admin@mydomain.com \
-e REGISTRY_STORAGE [...] \
-e REGISTRY_AUTH [...] \
registry:2
# Then I got the strangest error when I tried to push an image (with multiple retrying... before it almost worked)
$ docker pull alpine
$ docker tag alpine registry.mydomaine.com/alpine
$ docker push registry.mydomaine.com/alpine
The push refers to a repository [registry.mydomain.com/alpine]
5bef742407: Pushing [==================================================>] 3.966MB/3.966MB
read tcp 10.0.2.17:55298->69.100.100.100:443: read: connection reset by peer
# The error was due to an typo in the variable REGISTRY_HTTP_HOST (I had the wrong extension .fr)
# CONCLUSION: if you use let's encrypt and get a read: connection reset by peer, double check your domain name!
# ------------------------------------------------------------------------------------ #
# BTW if you want to see the full docker run command with swift and basic auth (there are too few examples on the Interweb)
# you should change the ** obviously
$ docker run -p 443:5000 -p 5001:5001 --name registry -d --restart=always \
-e REGISTRY_STORAGE=swift \
-e REGISTRY_STORAGE_SWIFT_CONTAINER=docker-registry \
-e REGISTRY_STORAGE_SWIFT_USERNAME=*** \
-e REGISTRY_STORAGE_SWIFT_AUTHURL=https://***.net/v2.0/ \
-e REGISTRY_STORAGE_SWIFT_TENANTID=*** \
-e REGISTRY_STORAGE_SWIFT_PASSWORD=*** \
-e REGISTRY_HTTP_ADDR=0.0.0.0:5000 \
-e REGISTRY_HTTP_HOST=https://registry.mydomain.com \
-e REGISTRY_HTTP_TLS_LETSENCRYPT_CACHEFILE=/etc/docker/registry/letsencrypt.json \
-e REGISTRY_HTTP_TLS_LETSENCRYPT_EMAIL=*** \
-v `pwd`/docker-registry-auth:/auth \
-e REGISTRY_AUTH=htpasswd \
-e REGISTRY_AUTH_HTPASSWD_REALM="Registry Realm" \
-e REGISTRY_AUTH_HTPASSWD_PATH="/auth/htpasswd" \
-e REGISTRY_HEALTH_STORAGEDRIVER_ENABLED=false \
-e REGISTRY_HTTP_DEBUG_ADDR=0.0.0.0:5001 \
registry:2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment