Cannot attach to container over internet

I run a Portainer instance to manage my containers. I have this Portainer configured to be accessible remotely over the internet via my own domain. I can log in and access Portainer perfectly fine, but when I try to attach to a container when connected via the internet, it just gets stuck attaching. When connecting via my local IP on my home network, it attaches immediately. Is there another port I need to forward? What am I doing wrong?

Usually services are listening on ports 80 (http) and 443 (https) for requests. Only one service can listen on a port at the same time.

If you want multiple services on the same IP, using different (sub-)domain names, then you need a reverse proxy like nginx, Traefik, caddy, haproxy to receive requests and forward them internally to the right service.

Automatic service discover works with nginx-proxy (real easy, doc) or Traefik (more complex, can handle Swarm, example). You just place env vars or labels on the container and the proxy will automatically create TLS certs and route to target.

Please, be more specific. What do you mean by attaching to the container? docker attach? Or you want to execute a shell command in the container? Or just want to access the potainer WEB UI from a remote machine? Please show what command you want to work and what error message you get.

This part is what confuses me. If you know which pot Portainer is using, ayou know which port you need to forward. If you want remote access, that depends on your internet provider and whether they allow you to access your machine over the internet. If they do, your router still could block the request. If that doesn’t, a firewall coul do that on the host you are working on.