Docker run script in host on docker-compose up

Ilh*_*cas 7 bash docker dockerfile docker-compose docker-machine

thank you for watching this question.

So my question relates to best practices on how to run a script on a docker-compose up directive.

Currently i'm sharing a volume between host and container to allow for the script changes to be visible to both host and container. Similar to a watching script polling for changes on configuration file.

The script has to act on host on changes according to predefined rules.

So my question is:

How could I start this script on a docker-compose up directive or even from the dockerfile of the service, so that whenever the container goes up the "watcher" can find any changes being made and writing to.

The container in question will always run over a debian / ubuntu OS and should be architecture independent, meaning it should be able to run on ARM as well.

Thanks in advance

I would like to know as well, why was the question downvoted just because some people don't understand it.

I wish to run a script on the Host, not inside the container.. I need the Host to change its network interface configurations to easily adapt any environment The HOST needs to change I repeat.. This should be seamless to the user, and easily editable on a Web interface running Inside a CONTAINER to adapt to new environments.

我目前使用基于crontab的主机上运行的脚本来执行此操作。我只想了解最佳实践和示例,了解如何从容器内部在HOST上运行脚本,以便安装操作员可以像部署docker-compose一样轻松进行部署。

谢谢

tgo*_*gos 5

我只是想知道如何从容器内部在主机上运行脚本的最佳实践和示例,以便安装操作员只需运行 docker-compose up 即可轻松部署

似乎没有可以应用于您的案例的最佳实践。这里提出的解决方法:How to run shell script on host from docker container? 就是使用一个client/server技巧。

  1. 主机应该运行一个小型服务器(选择一个端口并指定您应该等待的请求类型)
  2. 容器启动后,应将此请求发送到该服务器
  3. 然后主机应该运行脚本/触发您想要的更改

这可能存在严重的安全问题,因此使用时需要您自担风险。