Debugging Containers

I’m new to Balena, Docker and Embedded Linux but I’m learning :smile: I ran into a situation yesterday where I had a container running on an RPi4 and it kept restarting. I wanted to ssh into that container to manually try executing the commands but I wasn’t able to start the container in interactive mode which I have done with Docker on my Mac.

  1. So in this situation how debug containers that keep restarting?
  2. Can they be started in interactive mode like Docker on a desktop?
  3. Can this be done without changing the Docker file and deploying it?

Thanks,

@WestCoastDaz I’m relatively new to the platform as well - so I’m afraid I can’t answer your questions, directly - but only give a +1 on the thread, as I had a similar experience in trying to start up the Octobalena device, on an RPi4, and had similar results (container continuously re-starting, as seen from the OS logs in the console - and unable to connect (to the container) via SSH.

It turns out, in my case (documented in this thread) the problem pertained to an underlying problem which was causing an incorrect build. This reminds me that I need to get back to that effort so that I can have a ‘development’ OctoPrint device (#ScratchMonkey) for some planned activities, without disrupting the ‘production’ one currently driving my printer.

Sorry I’m not more help, but I’ll watch this thread to see what I can learn!

1 Like

Hi,

The container restarts due to critical runtime errors right? Usually you can open terminal on balena dashboard, select a service and run any command from there, but if the container is in restart loop, you will be disconnected. To solve this you could handle errors so that the process won’t exit. You can also observe logs on the dashboard.

The fastest way to develop on balena is to use local push, so that your changes get applied very quickly.

@karaxuna Is it possible to start a container with a just a shell so that I can experiment?

It sure is. If you open a shell to the Host OS on a device from the dashboard (or SSH into your development mode enabled device using the Balena CLI), you should be able to run a shell in a new container with balena run -it your_image:tag /bin/bash. For example, you can run htop from the host OS with: balena run --rm -it --privileged --pid=host wrboyce/utils:htop.