0

I'm working on an OpenERP project where I'm working on a few custom modules. I have a 3 container setup:

  • app: OpenERP service running here
  • db: PostgreSQL service, nothing else
  • data: only a volume directory and serves as a data provider for 'app' container

It's working fine but if I want to work on the files in the data container I don't know what is the fastest and best way to use proper IDE and if I'm done, commit the code and actually keep it after I shut the container down?

One approach would be to create another container with shared X11 service and lach onto that with a GUI based IDE or something similar but this seems a bit overkill for me.

Regarding version control: I have a remote git repo that might be good for storing the changes but as soon as I build the image from a Dockerfile and spin it up, it can't clone the repo because it only allows SSH connection and the container doesn't have it.

I found several articles and blog posts about shared data containers and how awesome they are. I haven't been able to found another where they discussed the actual development and committing of the code on these data conatiners.

Thoughts?

4

1 回答 1

2

您不需要具有共享 X11 服务的容器或使用 git 从容器中克隆您的代码仓库。

对于开发,您可以使用“数据”容器中的卷安装代码文件夹,然后您的“应用”容器将看到这些文件(请参阅https://docs.docker.com/userguide/dockervolumes/):

sudo docker run -d -P --name data -v /src/webapp:/opt/webapp my/container

由于此文件夹将在主机中,因此将在“数据”容器关闭后保留。您还可以使用自己喜欢的 IDE 来编辑代码。

对于生产,您可以将代码文件夹添加到容器映像本身中,以便直接部署容器。在您的 Dockerfile 中:

ADD /home/user/webapp /opt/webapp

另外,请参阅在 docker 容器中嵌入代码或将其安装为卷?简要讨论这种方法。

于 2014-11-29T10:49:00.483 回答