Docker在Docker上的主机中运行脚本-编写 [英] Docker run script in host on docker-compose up

查看:184
本文介绍了Docker在Docker上的主机中运行脚本-编写的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

感谢您观看这个问题.

所以我的问题与如何在docker-compose up指令上运行脚本的最佳实践有关.

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.

所以我的问题是:

我该如何在docker-compose up指令或什至从服务的dockerfile上启动此脚本,以便每当容器启动时,观察者"就可以找到正在进行的任何更改并写入其中.

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.

有问题的容器将始终在debian/ubuntu OS上运行,并且应独立于体系结构,这意味着它也应能够在ARM上运行.

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.

预先感谢

我也想知道,为什么只是因为有些人不理解这个问题而否决了这个问题.

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

我希望在主机上而不是在容器内部运行脚本.我需要主机更改其网络接口配置,以轻松适应任何环境重复我的主机需要更改..这对用户应该是无缝的,并且可以在CONTAINER内部运行的Web界面上轻松进行编辑以适应新环境.

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的主机上运行的脚本来执行此操作.我只想了解最佳实践和示例,了解如何从INSIDE CONTAINER在HOST上运行脚本,以便部署操作员可以像安装docker-compose一样容易地进行部署.

I currently do this with a script running on the host based on crontab. I just wish to know the best practices and examples of how to run a script on HOST from INSIDE a CONTAINER, so that the deploy can be as easy for the installing operator to just run docker-compose up.

谢谢

推荐答案

我只想了解最佳实践和示例,以了解如何从INSIDE CONTAINER在HOST上运行脚本,从而使安装操作员可以像部署docker-compose up一样容易地进行部署

I just wish to know the best practices and examples of how to run a script on HOST from INSIDE a CONTAINER, so that the deploy can be as easy for the installing operator to just run docker-compose up

似乎没有适用于您的案例的最佳实践.此处提出了一种解决方法:如何在主机上运行shell脚本是从docker容器中获取的?是要使用client/server技巧.

It seems that there is no best practice that can be applied to your case. A workaround proposed here: How to run shell script on host from docker container? is to use a client/server trick.

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

这可能会带来严重的安全问题,因此使用后果自负.

This is something that might have serious security issues, so use at your own risk.

这篇关于Docker在Docker上的主机中运行脚本-编写的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆