我的本地Eclipse可以在Docker容器中安装访问库吗? [英] Can my Local Eclipse Install Access Libraries in Docker Container?

查看:136
本文介绍了我的本地Eclipse可以在Docker容器中安装访问库吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个用于Django开发的Docker映像,并且通过一些xauthority文件机制,我从容器中使用了Eclipse。在大多数情况下,Eclipse都可以很好地运行,但是有一些令人困扰的问题似乎与它在容器中运行有关。毕竟,Docker并不是真正为此目的而开发的。因此,我想知道...

I have a Docker image that I use for Django development, and via some xauthority file mechanics, I use Eclipse from within the container. For the most part, Eclipse works well, but there are a few nagging issues that seem to be related to the fact it's running inside a container; after all, Docker wasn't really developed for this purpose. So, I wonder...

如果我在本地计算机上运行Eclipse的实例,是否可以配置给定项目以访问安装在运行容器中的库?也就是说,它可以解析导入,是否可以使用Python 2或3 / Django 1或2运行代码,具体取决于单个项目及其所访问的容器?

If I run an instance of Eclipse on my local machine, can I configure a given project to access the libraries installed in a running container? That is, have it resolve imports, run code using Python 2 or 3/Django 1 or 2 depending on the individual project and the container it's accessing?

主机:CentOS 7

Host Machine: CentOS 7

基本映像:Ubuntu 16.04

Base Image: Ubuntu 16.04

添加的信息:
这是我的运行命令(在xauth之前有一些脚本),显示了如何将卷安装到给定的Docker环境:

Added Info: Here is my run command(thought there is some scripting that precedes it for the xauth stuff), which shows how I mount my volumes to a given Docker environment:

docker run -h django-env \
-d -p 8000:8000 \
-w=/home/$USER \
--user $USER \
-v $XAUTH:$XAUTH -v $XSOCK:$XSOCK \
-v psql_var_lib:/var/lib/postgresql \
-v psql_var_log:/var/log/postgresql \
-v psql_var_etc:/etc/postgresql \
--mount type=bind,source=$LOCAL_REPO/django-env-opt,target=/opt \
--mount type=bind,source=$LOCAL_REPO/django-env-home,target=/home/$USER \
-e XAUTHORITY=$XAUTH -e DISPLAY \
--entrypoint "" hildy:django_python1 bash -c "sudo /etc/init.d/postgresql 
start && /opt/eclipse/eclipse/eclipse"


推荐答案


我从

I use Eclipse from within the container.

您不需要。容器的目的是为您提供一个编译环境。只要您可以在容器和主机之间共享文件,所有代码编辑都可以在本地Eclipse中进行。

You don’t need to. The purpose of the container is to provide you with a compilation environment. As long as you can share files between the container and host, all code editing can happen from your local eclipse.

所以问题是如何共享文件?通过卷。最简单的方法是说 docker run -v< hostdir>:< containerdir>

So the question is how do you share files? Via volumes. The simplest way is to say docker run -v <hostdir>:<containerdir>.

Ref: https://docs.docker.com/storage/volumes/

这篇关于我的本地Eclipse可以在Docker容器中安装访问库吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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