2017-01-08 10 views
1

docker-cookiecutterテンプレートをdocker & docker-composerで設定しました。 私は以下の私が得るもののいずれかを使用しようとしているときに、事前に設定Djangoの管理コマンド(のrunserver、移行、など)docker-composeで動作するようにPyCharmを設定する

が付属しています:

 
ad381d177c42:python -u /opt/.pycharm_helpers/pycharm/django_test_manage.py test . /app 
Testing started at 2:17 ... 
Creating test database for alias 'default'... 
/usr/local/lib/python3.5/site-packages/environ/environ.py:608: UserWarning: /app/config/settings/.env doesn't exist - if you're not configuring your environment separately, create one. 
    "environment separately, create one." % env_file) 
/usr/local/lib/python3.5/site-packages/django/db/backends/postgresql/base.py:248: RuntimeWarning: Normally Django will use a connection to the 'postgres' database to avoid running initialization queries against the production database when it's not needed (for example, when running tests). Django was unable to create a connection to the 'postgres' database and will use the default database instead. 
    RuntimeWarning 
Traceback (most recent call last): 
    File "/usr/local/lib/python3.5/site-packages/django/db/backends/base/base.py", line 199, in ensure_connection 
    self.connect() 
    File "/usr/local/lib/python3.5/site-packages/django/db/backends/base/base.py", line 171, in connect 
    self.connection = self.get_new_connection(conn_params) 
    File "/usr/local/lib/python3.5/site-packages/django/db/backends/postgresql/base.py", line 176, in get_new_connection 
    connection = Database.connect(**conn_params) 
    File "/usr/local/lib/python3.5/site-packages/psycopg2/__init__.py", line 164, in connect 
    conn = _connect(dsn, connection_factory=connection_factory, async=async) 
psycopg2.OperationalError: could not connect to server: No such file or directory 
    Is the server running locally and accepting 
    connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"? 

docker-compose up非常によく働いて。ここで

docker-compose.ymlです:

 
version: '2' 

volumes: 
    postgres_data_dev: {} 
    postgres_backup_dev: {} 

services: 
    postgres: 
    build: ./compose/postgres 
    volumes: 
     - postgres_data_dev:/var/lib/postgresql/data 
     - postgres_backup_dev:/backups 
    environment: 
     - POSTGRES_USER=budger 

    django: 
    build: 
     context: . 
     dockerfile: ./compose/django/Dockerfile-dev 
    command: /start-dev.sh 
    depends_on: 
     - postgres 
    environment: 
     - POSTGRES_USER=budger 
     - USE_DOCKER=yes 
    volumes: 
     - .:/app 
    ports: 
     - "8000:8000" 
    links: 
     - postgres 
     - mailhog 

    pycharm: 
    build: 
     context: . 
     dockerfile: ./compose/django/Dockerfile-dev 
    depends_on: 
     - postgres 
    environment: 
     - POSTGRES_USER=budger 
    volumes: 
     - .:/app 
    links: 
     - postgres 

    mailhog: 
    image: mailhog/mailhog 
    ports: 
     - "8025:8025" 

PyCharmインタプリタの設定:

django docker-compose service interpreter

pycharm docker-compose service interpreter

もう一度、すべてが魔法のようにではなく、PyCharmで働いているようだ:(

本当に助けてもらえますか?ありがとう!

答えて

1

問題の原因が見つかりました。 PyCharm 2016.3.2ではEntrypointは無視されます。 2016年2月3日にPyCharmを元に戻す

Ticket on Jetbrains bugtracker

は、すべての作業を行います。

+1

私はPyCharmを最新バージョン(2016.3.2)にアップデートしていますが、問題は解決したようです。 – miso

関連する問題