portainer: Can't connect to container console

Bug description Can’t connect to container console. When I click the connect, it will show connecting for a few seconds, and then flashes to the same page. Network are:

  • /api/endpoints/1/docker/containers/63c8b179e7df47e7add9b3ff7e55dabd23d027f19cd3e7cd5c1af1370f574623/exec returns 201
  • ws://localhost:9000/api/websocket/exec?token=xxx&endpointId=1&id=xxx returns 101
  • /api/endpoints/1/docker/exec/ba12c1bb7a6b275efbc2a8d51e3e72ecc7406f68ff1d57c45047fa5321411b7d/resize?h=31&w=117 returns 404
  • /api/endpoints/1/docker/exec/ba12c1bb7a6b275efbc2a8d51e3e72ecc7406f68ff1d57c45047fa5321411b7d/resize?h=30&w=116 returns 404

Expected behavior A console appears

Portainer Logs

2020/06/19 17:07:15 Warning: the --template-file flag is deprecated and will likely be removed in a future version of Portainer.
2020/06/19 17:07:16 server: Reverse tunnelling enabled
2020/06/19 17:07:16 server: Fingerprint d2:ca:34:4b:73:ef:26:c5:f5:98:1f:e1:76:52:29:d5
2020/06/19 17:07:16 server: Listening on 0.0.0.0:8000...
2020/06/19 17:07:16 Starting Portainer 1.24.0 on :9000
2020/06/19 17:07:16 [DEBUG] [chisel, monitoring] [check_interval_seconds: 10.000000] [message: starting tunnel management process]
2020/06/19 17:07:38 http error: No administrator account found inside the database (err=Object not found inside the database) (code=404)
2020/06/19 17:07:38 http error: No administrator account found inside the database (err=Object not found inside the database) (code=404)

Steps to reproduce the issue:

  1. Create a new container (such as portainer)
  2. Go to Exec console
  3. Click connect

Technical details:

  • Portainer version: 1.24.0
  • Docker version (managed by Portainer): 19.03.8
  • Platform (windows/linux): Windows, Ubuntu 18.04
  • Command used to start Portainer (docker run -p 9000:9000 portainer/portainer): docker run -d -p 8000:8000 -p 9000:9000 --name=portainer --restart=always -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer
  • Browser: Edge Chromium and Firefox

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 29 (2 by maintainers)

Commits related to this issue

Most upvoted comments

I had the same issue. What helped me was: #https://github.com/portainer/portainer/issues/6353 ; enable Websockets Support in Nginx Proxy Manager.

@bannert1337’s answer pointed me into the right direction:

I had the same issue when running portainer behind an NginX reverse proxy setup. Adding the following lines to the location field of the nginx server configuration solved it for me:

proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";

@bannert1337’s answer pointed me into the right direction:

I had the same issue when running portainer behind an NginX reverse proxy setup. Adding the following lines to the location field of the nginx server configuration solved it for me:

proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";

Awesome! Finally have mine back working now too. On Synology Reverse Proxy, configurations is slightly different, as follows:

  1. From ‘Control Panel’ -> ‘Login Portal’ -> Advanced -> Reverse Proxy, edit the relevant Portainer entry
  2. Select ‘Custom Header’ -> Click on ‘Create’ and select ‘Web Socket’
  3. Under ‘Advanced Settings’ select ‘HTTP 1.1’ from the Proxy HTTP Version
  4. Hit ‘Save’, and it works

+1 Same here. Infinite connection appeared since version 2.11.1

all containers that I have using cli “docker exec -it id-container sh” succeed, when using portainer I can’t console all my containers

I am using nginx proxy mnanager. And I forgot to enable Websockets Support in the proxy host configuration. Now, I’ve enables it and it’s working for me.

What is the container image you are using?

Many containers do not offer console support, or if they do, its not /bin/bash but /bin/sh (its why we let you change the shell).

I had the same issue. What helped me was: #https://github.com/portainer/portainer/issues/6353 ; enable Websockets Support in Nginx Proxy Manager.

Working for me. It would be great if portainer would throw some error if possible in the case of websockets not available.