can a dockerised app execute script on the host?
If I have an application running in a docker container, is it possible to have it execute a shell script on the host? I’m pretty sure there is no way to achieve this – on purpose, such is the nature of containers – but want to check. Thanks.
EDIT: and failing that, is there a way for the app to interact with the docker engine running on the host so that it can trigger a “docker stop” “docker run..” etc for other containers.
One Solution collect form web for “can a dockerised app execute script on the host?”
Well, technically, it does. Processes are run on the host even when from inside a container. You can verify this when running
ps aux as root on the host : you’ll see the dockerized processes.
The question is : what interaction is your script supposed to have with the system ? If it’s taking files as input, accessing databases or network resource, then all of this is possible for a dockerized script. You’ll just have to define volumes and links.
About the docker engine : yes it is also possible for a container to control its own docker engine. You just have to add this to the docker command :
That way, a docker client (inside the container) will have access to the docker engine (via docker API).