ofelia icon indicating copy to clipboard operation
ofelia copied to clipboard

Running ofelia when a container is stopped?

Open gremo opened this issue 5 years ago • 6 comments

I know that this is probably a weird question and that is something more related to the host OS scheduler... anyways, would be possible use ofelia to just start a container?

There are a lot of Docker images which just starts, do their job (probabily using an entrypoint script)... and then... exit.

gremo avatar Feb 18 '20 16:02 gremo

The main feature of Ofelia is the ability to execute commands directly on Docker containers. Using Docker's API Ofelia emulates the behavior of exec, be in able to run a command inside of a running container. Also you can run the command in a new container destroying it at the end of the execution.

or I'm missing what you're asking?

kamko avatar Feb 28 '20 18:02 kamko

@gremo, can you explain your use-case in more detail? @kamko is right, ofelia is designed to start containers. Or you mean to start a container without specifying the command so it starts with the default one, which was set when container was built?

taraspos avatar Feb 28 '20 21:02 taraspos

Thank you both. Maybe it's my english, I'll try to explain better... or maybe I'm missing somethig.

Take a simple image (container) that starts, do it's job, and then quits. If I schedule to run something in the container, using ofelia, will it work even if the container is stopped (not running at the time ofelia runs the job)?

gremo avatar Feb 29 '20 12:02 gremo

Hmmm... job-exec will not work, because it is impossible to exec into a stopped container. Docker will throw Error response from daemon: Container 1abc123 is not running.

taraspos avatar Feb 29 '20 12:02 taraspos

but if it is one-off container then you can simply create new container every run?

kamko avatar Mar 02 '20 12:03 kamko

I'm looking to do something like this as a workaround to https://github.com/mcuadros/ofelia/issues/70.

I have a one-off container that needs environment variables, volumes, and to be run on a schedule. It doesn't seem like Ofelia can do this at the moment. The closest I can see would be job-run, but that seems to require the container to be named exactly (so Docker labels aren't as useful), and to be a "service container".

magneticflux- avatar Mar 20 '20 04:03 magneticflux-