How to restart octoprint in official docker container

I have installed the octoprint docker container. There was no default setting for octoprint restart command on install and following the 'non container' instructions for restart command (sudo service restart octoprint) this failed as sudo isn't installed. Octoprint is also not installed as a service when accessing the docker container.

Is there a preferred command to restart octoprint within the docker container?

i'm looking for a solution for that as well
couldn't understand the way to restart the container or the service inside with a command in the octoprint

I suppose there's always the Docker documentation on this.

I assume they mean the commands to pass into the application setting to restart octoprint within the inside of docker, since the OS is pretty stripped down...

That's exactly the problem. Ideally it'd be great to restart the container, but the command is sent withint the container and there is no systemd/init.d setup within for the images I've been using to address this.

All I can think to do is kill the process and restart it.

I'm not sure you can restart a container from within a container.

BenC

yeah, it's definitely using a very lightweight docker image. It would be nice if it ran a small os with possibly systemd to intiate restarts of the service.

Haven't tested yet, but you could :

  • create your own Dockerfile (enhancing the base octoprint image = using it as the FROM in your dockerfile)
  • add the docker-ce-cli client (per the docker documentation about adding docker inside debian = add repository, gpg key, ... + apt-get install docker-ce-cli)
  • mount the docker socket when starting your enhanced octoprint container (with an additional -v /run/docker.sock:/run/docker.sock)
  • reconfigure octoprint to use the docker commands ("docker restart octoprint")

Provided there is no issue about installaing docker-ce-cli inside the used debian image, this should work flawlessly (this is what images like "portainer" are doing in order to be able to administrate hosts' containers from the portainer image itself).

I am a total newbie, so not sure if this adds anything or not, but I am running a container based on nunofgs/docker-octoprint, and in that case this command works perfectly:

supervisorctl restart octoprint

Now testing the official octoprint/octoprint image, and the above does not work anymore...maybe someone smarter than me can make something out of that..

Hopefully someone will repackage the docker image without the stripped down OS so that we can restart with OctoPrint. Meanwhile, I'll do a restart with Portainer...

I have a command line that works for me now. I did some inquiry on the OctoPrint/octoprint-docker github site and after a couple of pointers and further web searches this is what I came up with:

redirfd -w 2 /dev/null s6-svscanctl -t /var/run/s6/services

2 Likes