Portainer - Why the console button doesn't work sometimes and how to fix it
When I started my docker journey just over 2 years ago in my home lab, I viewed it as a way of deploying pre-existing applications that other people had created rather than making my own. I was pretty lucky that all the Docker applications I downloaded and ran were created using pre-existing Docker Compose files. Unfortunately, it didn’t truly allow me to understand what was going on behind the scenes.
These files had set up the containers in such a way that would allow access to the console. It was great! Click the console button and boom! SSH access to the docker container via a browser. Being able to console into the container, allows a person to troubleshoot the container so much easier. It also makes it feel closer to a VM rather than a container.
The docker images I have been creating from scratch did NOT allow me to console into the docker container. Using both the command line and Portainer, I could see that the images were up and running and everything seemed ok. I asked myself why doesn’t this darn button work.
As I looked into things I quickly realized I couldn’t use the terminal on the newly created containers because I didn’t use the “Interactive” flag when I ran the “Docker Run” commands or the flipped switch that turns on Interactive mode in Portainer.
If the docker container isn’t set up and/or “run correctly”, the console button can still be clicked on, and the console button will just not work. It would be nice if Portainer would help the user by giving an error or giving a better error than the one it sometimes gives. If Portainer knows that the image is NOT in interactive mode, why would the button be still enabled to be clicked on?
You can tell if the container can use the terminal by opening Portainer, clicking on the “Container” link on the far left side
Clicking on the Docker Container in question and then clicking on “Inspect”. You will need to scroll way down to the “HostConfig” section and find “Init”. If it says “true”, you most likely will be able to console into the Docker Container image. If it says “False” you will NOT be able to. The “Interactive” mode can only be set at creation time. So if it is set to false you will need to re-create the Docker Container.
Additional Info I found
There are two ways in which you can interact with a running container
attach
exec
--interactive flag
Keep STDIN open even if not attached
It will read inputs from your terminal/console and present output. If you run docker
attach
Attach to a running process
If the docker container was started using /bin/bash command, you can access it using attach, if not then you need to execute the command to create a bash instance inside the container using exec.
More in-depth: If the docker container is started using /bin/bash then it becomes containers PID 1 and attach the command will attach you to PID 1.
exec
Creates new process
If you want to create a new process inside the container then exec it like exec is used to execute apt-get command inside the container without attaching to it or running a node or Python script.
Eg: docker exec -it django-prod python migrate
See here -i is for interactive and -t is for --tty that is pseudo-TTY. Interactive so that you can enter if something is prompted by this command.
Docker Run HELP - This link has a ton of info and all the flags you can use when creating the Docker Container.






