I am trying to create a docker-based development box for our django application. It works smoothly.
None of my team members will take care of this until there is a nice IDE integration, so I play the new and brilliant Docker Support in pycharm 5 .
I followed the related documentation and pycharm recognizes my web container and python interpreter.
Here is my docker-compose.yml:
web: build: . ports: - "8000:8000" volumes: - .:/srv/app links: - database - search - cache entrypoint: /home/deployer/web-entrypoint.sh worker: build: . volumes: - .:/srv/app command: celery -A core worker -l info links: - database - search - cache database: image: postgres:latest volumes_from: - data environment: - POSTGRES_USER=app_user - POSTGRES_PASSWORD=app_password data: image: busybox volumes: - /var/lib/postgresql/data search: image: "elasticsearch:1.7" command: "elasticsearch --http.bind_host=0.0.0.0" ports: - "9200:9200" cache: image: "redis:latest" ports: - "6379"
Unfortunately, pycharm does not support docker-compose support, so djangos runserver could not connect to the database. So I copied the (supposedly predictable) aliases from the /etc/host web container:
DATABASES = { 'default': { 'ENGINE': 'django.db.backends.postgresql_psycopg2', 'NAME': 'app_db', 'USER': 'app_user', 'PASSWORD': 'app_password', 'HOST': 'docker_database_1', 'PORT': '5432', } } HAYSTACK_CONNECTIONS = { 'default': { 'ENGINE': 'haystack.backends.elasticsearch_backend.ElasticsearchSearchEngine', 'URL': 'http://docker_search_1:9200/', 'INDEX_NAME': 'app', }, } BROKER_URL = 'redis://docker_cache_1:6379/0' CELERY_RESULT_BACKEND = BROKER_URL
Now the database connection error no longer exists, but the output from my django server gives me the following:
a6993f56e61e:python -u /opt/project/manage.py runserver docker:8001 --traceback Performing system checks... System check identified no issues (0 silenced). November 08, 2015 - 19:54:29 Django version 1.8.6, using settings 'core.settings.dev' Starting development server at http://docker:8001/ Quit the server with CONTROL-C. Error: [Errno -2] Name or service not known Process finished with exit code 1
No stack trace, only that.
What is strange: python -u /opt/project/manage.py - what is it? The folder does not exist on the host and in the container.
My Django Server conf:

I also tried clean-python, like this:

This is like mega-confusion because it tries to connect again through the "database" link, even if I remove it from the settings at all.
What will be the next steps for debugging?
Bonus question: pyCharm recognizes installed packages in the project settings, but cannot find it in the code, why?

UPDATE
I found out that pyCharm runs the container for itself and does not use the existing docker container. Therefore, it seems that pyCharm can only work with one container, which does not seem to be that useful.