使用Atom / Sublime-Text编辑Docker容器FS? [英] Editing Docker container FS using Atom/Sublime-Text?

查看:1330
本文介绍了使用Atom / Sublime-Text编辑Docker容器FS?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在boot2docker的帮助下运行OSX和Docker。



从我的理解,boot2docker是运行docker容器的轻量级linux发行版。我有一些Ubuntu容器,用于运行和测试在Linux上应该特别运行的项目。



但是,从我选择的主机文本编辑器中改变每个小代码,都需要我重新构建镜像并重新运行容器。运行应用程序,确认我所做的更改没有打破任何事情。



有没有办法在主机上的文本编辑器中打开Docker容器FS文件夹? (a.k.a远程编辑?)



有你们中的任何一个人做这个吗?任何想法都会很棒我想在Docker容器上设置SFTP或SSHD,但我想要你的意见?

解决方案

我经常做的是,在开发中,将应用程序的源代码挂载到中通常的位置。然后,我将容器的命令(或entrypoint)设置为以开发模式启动的脚本(例如,通过使用 nodemon 为一个node.js应用程序,在Rails中设置 RAILS_ENV = development 等等。)



do 在Mac OS X(和我假设Windows)下,在boot2docker或docker-machine下运行,需要注意的是,您需要在主目录下方的某个地方工作。 >

有一个具体的例子,我设置了存储库成分:


  1. script / dev 是我的dev-mode入口点。它启动了nodemon下的主要应用程序。

  2. 当我启动容器时,我将源目录作为卷安装到容器中将.yml#L36rel =nofollow>设置为 script / dev 。 (我在这里使用 docker-compose 启动并链接上游依赖关系,所以我可以做一个命令中的一切。)

有了这两个东西,我可以运行 docker-compose up / code>,在我主机上选择的任何编辑器进行源代码更改,保存文件,并在容器内自动重新加载服务,使我的更改生效。 Presto!


I'm running OSX and Docker with the help of boot2docker.

From my understanding boot2docker is a lightweight linux distro that is running the docker containers. I have some Ubuntu containers that I use to run and test projects that should specifically run well on Linux.

However every small code change from my host text editor of choice, requires me to re-build image and re-run the container. Run the app and confirm that the change I made didn't break something.

Is there a way for me to open a Docker container FS folder in a text editor from my host machine? (a.k.a Remote edit?)

Have any of you guys done this? Any ideas will be awesome. I think about setuping SFTP or SSHD on the Docker container, but I would want your opinion?

解决方案

What I often do is, in development, mount the source code of the application to its usual place in a volume. Then, I set the command (or entrypoint) of the container to a script that launches it in "development mode" (for example, by using nodemon for a node.js application, setting RAILS_ENV=development in Rails, and so on).

Volumes do work on Mac OS X (and I assume Windows) under boot2docker or docker-machine, with the caveat that you need to be working somewhere beneath your home directory.

For a concrete example, here's a repository that I set this up in. The ingredients:

  1. script/dev is my "dev-mode" entrypoint. It launches the main application under nodemon.
  2. When I launch the container, I mount the source directory into the container as a volume and set script/dev as the command. (I'm using docker-compose here to launch and link in an upstream dependency, so I can do everything in one command.)

With those two things in place, I can run docker-compose up, make a source change in whatever editor I choose on my host, save the file, and the service within the container auto-reloads to bring my changes into effect. Presto!

这篇关于使用Atom / Sublime-Text编辑Docker容器FS?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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