Closed aofei closed 1 year ago
Yeah as you saw, things changed a lot because S6 is no longer used.
If you describe your needs we can see if there is alternate ways to do the same thing. For example, I see multiple ways to automatically stop the container after a certain amount time.
The other alternative is to stick to the previous version by using the proper Docker image tag.
If you describe your needs we can see if there is alternate ways to do the same thing.
All I want is to be able to have it automatically execute a script after Firefox has successfully started without writing a Dockerfile. Mounting the script to /etc/cont-init.d
might be an option, but I don't know how to monitor whether Firefox has successfully started.
For example, I see multiple ways to automatically stop the container after a certain amount time.
May I ask what is your best advice for automatically stopping containers?
You can probably mount a new "service" under /etc/services.d
. This service can be "one shot", meaning that it is executed once. See https://github.com/jlesage/docker-baseimage#services for more details on how to define a service.
Basically, you should mount a new directory (e.g. /etc/services.d/my_script
) that contains the following files:
run
: The script to run (file must be executable).app.dep
: Add a dependency on the app
service, i.e on Firefox. Thus, the service is started after Firefox is started.You should also add/mount the file /etc/services.d/default/my_script.dep
to make your service part of defaults ones.
To automatically stop the container, could you do it "externally" ? Example:
docker run -d --name firefox -p 5900:5900 --shm-size 2g
sleep 300
docker stop firefox
To automatically stop the container, could you do it "externally" ? Example:
My batch jobs are fired by nomad, so getting the docker stop
to work is a bit hacky.
You can probably mount a new "service" under
/etc/services.d
.
So I ended up choosing this way. And it works. Thanks for your help! ❤️
Great!
Before, I used to do something special by moving
/init
toENTRYPOINT
and overridingCMD
. Like automatically stopping the container after running for a while:This is all thanks to the previous
/init
file:But with the latest version it is no longer possible to do so. Because
/init
file was completely changed, support for$@
has been removed. I don't know if this is intentional, so I wonder if it's possible to add it back? I have a lot of batch jobs relying on this feature, so it's kinda important to me.