title: Docker compose: Traefik and Docker registry
body: <p>My PC is a Windows 10 PRO with Docker Desktop CE Version 2.0.0.3 (31259) (Engine 18.09.2).</p>
  
  <p>I'm building a <code>docker-compose.yml</code> file which runs Traefik, Portainer, GitLab, Jenkins and Registry containers.
  <strong>Traefik is configured with SSL</strong> (self-signed certificate).
  I've achieved to run the containers in their domains:</p>
  
  <ul>
  <li>Traefik: <a href="https://traefik.localhost" rel="nofollow noreferrer">https://traefik.localhost</a></li>
  <li>Portainer: <a href="https://portainer.localhost" rel="nofollow noreferrer">https://portainer.localhost</a></li>
  <li>Gitlab: <a href="https://gitlab.localhost" rel="nofollow noreferrer">https://gitlab.localhost</a></li>
  <li>Jenkins: <a href="https://jenkins.localhost" rel="nofollow noreferrer">https://jenkins.localhost</a></li>
  <li>Registry: <a href="https://registry.localhost" rel="nofollow noreferrer">https://registry.localhost</a></li>
  </ul>
  
  <p>When I run these URLs in a browser it returns me certificate error but I access web clients without problems.
  If I access the URL <code>https://registry.localhost/v2/_catalog</code> from the browser I can read: <code>{"repositories":[]}</code> This is good. I just started my Registry and it's empty.</p>
  
  <p>I generated the self-signed certificate with:</p>
  
  <pre><code>"C:\Program Files\OpenSSL-Win64\bin\openssl.exe" req -x509 -nodes -days 365 -newkey rsa:2048 -keyout traefik.key -out traefik.crt
  </code></pre>
  
  <p>I attach the configuration files. I omit part of the <code>docker-compose.yml</code> for short. </p>
  
  <p><strong>docker-compose.yml</strong></p>
  
  <pre><code>version: '3.7'
  
  services:
    traefik:
      image: traefik
      container_name: traefik
      ports:
        - "80:80"
        - "443:443"
      volumes:
        - /var/run/docker.sock:/var/run/docker.sock
        - D:\docker-vols\paas\traefik\traefik.toml:/traefik.toml
        - D:\docker-vols\paas\traefik\certs:/certs/
      labels:
        traefik.enable: true
        traefik.frontend.rule: "Host:traefik.localhost"
        traefik.port: 8080
        # Escapar $ con otro $
        traefik.frontend.auth.basic: "root:$$apr1$$3sEZB9aF$$y8ii5P4E8/KAhCiyQoS8I0"
  #  portainer:
  # ...
  #  gitlab:
  # ...
  #  jenkins:
  # ...
    registry:
      image: registry:2
      container_name: registry
      volumes:
        - D:\docker-vols\paas\registry\registry:/var/lib/registry
      labels:
        traefik.enable: true
        traefik.frontend.rule: "Host:registry.localhost"
        traefik.port: 5000
  </code></pre>
  
  <p><strong>traefik.toml</strong></p>
  
  <pre><code>defaultEntryPoints = ["http", "https"]
  [entryPoints]
    [entryPoints.http]
    address = ":80"
      [entryPoints.http.redirect]
      entryPoint = "https"
    [entryPoints.https]
    address = ":443"
    [entryPoints.https.tls]
      [[entryPoints.https.tls.certificates]]
        certFile = "/certs/traefik.crt"
        keyFile = "/certs/traefik.key"
  
  [api]
  
  [docker]
    endpoint = "unix:///var/run/docker.sock"
    domain = "docker.localhost"
    watch = true
    exposedbydefault = false
  </code></pre>
  
  <p>I run it: <code>docker-compose up</code></p>
  
  <p>My problem comes when I want to push an image to my Registry from the host (my Windows PC) to test that it works perfectly. I follow the next steps:</p>
  
  <pre><code>docker pull hello-world
  docker tag hello-world registry.localhost/my-hello-world
  docker push registry.localhost/my-hello-world
  </code></pre>
  
  <p>Then it returns</p>
  
  <pre><code>The push refers to repository [registry.localhost/my-hello-world]
  Get https://registry.localhost/v2/: dial tcp: lookup registry.localhost on 192.168.65.1:53: no such host
  </code></pre>
  
  <p>Where's my mistake? Thank you.</p>
  
  <hr>
  
  <h2><strong>SOLUTION:</strong></h2>
  
  <p>I forgot to add to <code>/etc/hosts</code>: </p>
  
  <pre><code>127.0.0.1 registry.localhost
  </code></pre>