Grails监视文件在Vagrant虚拟机中运行的Docker容器中不起作用 [英] Grails watch files doesn't work inside Docker container running inside a Vagrant virtual machine

查看:70
本文介绍了Grails监视文件在Vagrant虚拟机中运行的Docker容器中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个相当嵌套的结构:

I have a fairly nested structure:


  1. 运行a ...的MacOSX工作站...

  2. Vagrant VirtualBox虚拟机,其中 ubuntu / trusty64 正在运行...

  3. 正在运行Docker容器...

  4. 我用Grails编写的应用程序

  1. MacOSX workstation running a...
  2. Vagrant VirtualBox virtual machine with ubuntu/trusty64 running a...
  3. Docker container running...
  4. my application written in Grails

每一层的配置方式是共享以下文件系统的一部分:上面的层。这样:

Every layer is configured in such a way as to share a portion of the file system from the layer above. This way:


  • 无业游民,在<$中使用 config.vm.synced_folder 指令c $ c> Vagrantfile

  • Docker,使用 -v 命令,如switch和<$ c $ Dockerfile

  • Vagrant, with config.vm.synced_folder directive in Vagrantfile
  • Docker, with the -v command like switch and VOLUME directive in the Dockerfile

中的c> VOLUME 指令这样,我可以在工作站上进行开发,并且底部的Grails应用程序应该(理想情况下)检测更改并即时重新编译/重新加载。当我在MacOSX上直接运行相同的应用程序时,该功能曾经可以使用,但是现在grails似乎完全没有意识到文件的更改。当然,如果我使用编辑器(在Docker容器内)打开文件,则确实会更改它们,实际上,如果我停止/重新启动grails应用程序,则会使用新代码。

This way I can do development on my workstation and the Grails application at the bottom should (ideally) detect changes and recompile/reload on the fly. This is a feature that used to work when I was running the same application straight on the MacOSX, but now grails seems totally unaware of file changes. Of course, if I open the files with an editor (inside the Docker container) they are indeed changed and in fact if I stop/restart the grails app the new code is used.

我不知道grails如何实现监视策略,但是如果它取决于某些操作系统级别的功能,我怀疑文件更改通知会丢失在链中的某个位置。

I don't know how grails implements the watch strategy, but if it depends on some operating system level feature I suspect that file change notifications get lost somewhere in the chain.

任何人都知道可能是什么原因和/或我该如何进行调试?

Anyone has an idea of what could be the cause and/or how I could go about debugging this?

推荐答案

我发现在容器内可见文件系统通知的最佳方法如下:

The best way I have found to have filesystem notifications visible within the container was as follows:


  1. 创建两个文件夹,一个用于映射项目,另一个用于 mirror

  2. 在第一个文件夹中映射项目

  3. 保留在容器中运行的后台脚本,将项目文件夹同步到 mirror

  4. 从镜像运行项目

  1. Create two folders, one to map the project and a "mirror"
  2. Map the project in the first folder
  3. Keep a background script running in the container, rsyncing the project folder to "mirror"
  4. Run the project from "mirror"

这可能不是最有效或最优雅的方法方式,埠这种方式对容器的用户是透明的。不需要运行其他脚本。

It may not be the most efficient or most elegant way, but this way was transparent to users of the container. No additional script needs to be run.

未在较大的项目中进行过测试,但就我而言,我没有意识到性能问题。

Not tested in a larger project, but in my case I did not realize performance issues.

https://github.com/altieres/docker-jekyll-s3

这篇关于Grails监视文件在Vagrant虚拟机中运行的Docker容器中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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