Python – Can my native Eclipse install access libraries in a Docker container?

Can my native Eclipse install access libraries in a Docker container?… here is a solution to the problem.

Can my native Eclipse install access libraries in a Docker container?

I have a Docker image for Django development, and I use Eclipse in my containers through some xauthority file mechanism. For the most part, Eclipse works fine, but there are some tricky issues that seem to be related to the fact that it runs inside the container; After all, Docker wasn’t really developed for this purpose. So, I want to know….

If I run an instance of Eclipse on my local machine, can I configure a given project to access libraries installed in a running container? That is, does it import, run code using Python 2 or 3/Django 1 or 2 resolution based on a single project and the containers it accesses?

Host: CentOS 7

Base image: Ubuntu 16.04

Additional Information:
Here’s my run command (think there was some script for xauth stuff before it) and it shows how I mount my volume 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"

Solution

I use Eclipse from within the container.

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

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

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

Related Problems and Solutions