码头与pycharm 5 [英] docker with pycharm 5
问题描述
我的团队成员都不会关心,直到有一个很好的IDE集成,所以我玩新的和闪亮的
我也尝试过像这样的纯python conf:
这就像大混蛋,因为它再次尝试通过数据库链接进行连接,即使我删除它从
调试的下一步是什么?
奖金问题:pyCharm在项目设置中识别已安装的软件包,但是在代码中找不到它,为什么?
更新
我发现pyCharm正在为自己启动容器,并且不使用现有的docker容器。因此,看起来pycharm只能使用单个容器,这根本似乎没有什么用。
它事实证明,pycharm 5每个项目只支持一个容器。基本上,这意味着Docker支持在pyCharm 5中是无用的。
在这里请求在Docker组合之上的多容器管理,等待您的upvote:
https://youtrack.jetbrains.com/issue / IDEA-137765
I try to build a docker-based development box for our django app. It's running smoothly.
None of my teammembers will care about that until there is a nice IDE integration, therefore I play the new and shiny Docker Support in pycharm 5.
I followed the linked documentation and pycharm does recognise my web container and it's python interpreter.
Here's 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 there is no docker-compose support in pycharm, that's why djangos runserver
failed upon connecting to the database. Therefore I copied the (fortunately predictable) aliases from the web container's /etc/host
:
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 is no longer there, but the output of my django server gives me this:
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, just this.
What's strange: python -u /opt/project/manage.py
- what's this? The folder does not exist on both host and the container.
My Django Server conf:
I tried as well a pure-python conf like this:
This is like mega-confusing because it tries again to connect via the "database" link, even if I remove it from the settings at all.
What would be the next steps for debugging?
Bonus question: pyCharm does recognize the installed packages in the project settings, but it can't find it in the code, why?
UPDATE
I found out that pyCharm is starting the container for itself and is not using the existing docker container. Hence it looks like pyCharm can only work with a single container, which does not seem to be that useful at all.
It turns out that pycharm 5 supports only one container per project. Basically that translates to "Docker support is useless in pyCharm 5".
Multi-container management on top of docker compose is requested here and is awaiting YOUR upvote:
https://youtrack.jetbrains.com/issue/IDEA-137765
这篇关于码头与pycharm 5的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!