Stopping containers through GUI (script to stop nightly)

Hi all,

I am trying to stop containers through the use of docker stop but seemingly some go into a “crashed” state instead of a stopped state, but doing this through the GUI it appears to gracefully stop them instead.

I am wanting to know how I can instead script them to stop using the same method the GUI is using.

Could anyone offer some suggestions on where to look.

TIA!

Use the API. You can access the API docs for your version through the GUI.

Okay, I am on the API documentation, not too experienced with API stuff although have got some stuff working in the past, is there API routes spcifically for stopping and starting containers?

I am looking here if I am in the right sections for docker things.
/api/docs/current/api_methods_docker.html

Edit:
Think I found it under app instead.
/api/docs/current/api_methods_app.stop.html
/api/docs/current/api_methods_app.start.html

Through use of GPT (thanks GPT), and your guidance, I now see I can stop and start apps using midclt call app.stop and midclt call app.start.

I couldn’t work out how to do this through API calls but that’s opened up my mind to doing other things in the future if need be.

Thanks for your help!

That’s what midclt does. But in Python, you could do something like this:

        apps = c.call("app.query")
        for app in apps:
            app_config = c.call("app.stop", (app["name"]), job=True)

See also:

…and as example code: