docker-composetraefikportainer

docker-compose for portainer with traefik v2 gives "failure: unable to retrieve server settings and status"


I currently have a hard time updating my traefik v1 containers to v2. I set up a traefik container with automatic http->https forwarding. Now I want to get portainer running with the following docker-compose file:

version: '3.3'
volumes:
  portainer: {}
networks:
  web:
    external: true
services:
  portainer:
    image: portainer/portainer:latest
    restart: always
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - portainer_data:/data
    command: |
      --no-analytics
      --data /data
      --admin-password "the_hashed_password"
      -H unix:///var/run/docker.sock
    networks:
      web:
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.portainer.entrypoints=websecure"
      - "traefik.http.routers.portainer.rule=Host(`portainer.myserver.domain`)"
      - "traefik.http.services.portainer.loadbalancer.server.port=9000"
      - "traefik.http.routers.portainer.tls=true"
      - "traefik.http.routers.portainer.tls.certresolver=leresolver"
      - "traefik.http.routers.portainer.middlewares=authportainer"
      # generate with: sudo docker run --rm -ti xmartlabs/htpasswd user password
      - "traefik.http.middlewares.authportainer.basicauth.users=myuser:my_hashed_password"

Now when I start the container with docker-compose up I get:

portainer_1  | 2020/04/19 16:10:04 Starting Portainer 1.23.2 on :9000
...
portainer_1  | 2020/04/19 16:10:04 server: Listening on 0.0.0.0:8000...

Accessing http://portainer.myserver.domain correctly forwards to https://portainer.myserver.domain. After authenticating with myuser, an empty page is shown with a fading message toast "Failure. Unable to retrieve server settings and status". With traefik v1 the setup used to work. What I don't understand is if I need to do anything with port 8000 (which I didn't in the old working environment).

How does one debug such a scenario?
What is wrong with my docker-compose file?

P.S. For brevity, I omitted the traefik configuration file. If wanted, I will add it (it works with simple containers).


Solution

  • After way too many hours I figured out two things:

    1. The browser was/is at fault here
    2. latest is not what it says (that one is unrelated but occurred to me during debugging)

    Regarding the browser - I use Firefox 78.0.1 and always worked on docker from one specific machine. It seems that some data was cached that should not have been cached, with the cache leading to the faulty page. I don't know if portainer stored some data in the browsers cache (like cookies), but making it forget about the site (see here) made portainer work normally. Note that pressing F5 or Shift+F5 didn't work here, neither did restarting the browser.

    If you encounter a similar issue, you can also load the page in a private window. Depending on your configuration of your brower, this should prevent it to use previously cached data.