前提・実現したいこと
Dockerでpython3のDjango環境を構築したいのですがエラー?が発生しており先に進めません。
どなたか解決方法に心当たりのある方教えていただけると本当に助かります。
発生している問題・エラーメッセージ
エラー内容
1.docker-compose run web django-admin.py startproject composeexample .を実行後 指定ディレクトリにcomposeexample ディレクトリが生成されずsettings.py等の内容の編集ができません。 2.docker-compose run web django-admin.py startproject composeexample .をまた実行すると --- CommandError: /code/manage.py already exists, overlaying a project or app into an existing directory won't replace conflicting files --- と生成されたかのような振る舞いをしています。 3.'2.を受けdocker-compose upは動くか確認のため実行したところ 下記のメッセージを表示してwebの方は冒頭にInvalid HTTP_HOST header: '192.168.99.100:8000'. You may need to add '192.168.99.100' to ALLOWED_HOSTS.表示されDjangoのHellow Worldのようなページが表示されません --- docker-compose upコマンド時のメッセージ djangotest_db_1 is up-to-date Creating djangotest_web_1 ... done Attaching to djangotest_db_1, djangotest_web_1 db_1 | The files belonging to this database system will be owned by user "postgres". db_1 | This user must also own the server process. db_1 | db_1 | The database cluster will be initialized with locale "en_US.utf8". db_1 | The default database encoding has accordingly been set to "UTF8". db_1 | The default text search configuration will be set to "english". db_1 | db_1 | Data page checksums are disabled. db_1 | db_1 | fixing permissions on existing directory /var/lib/postgresql/data ... ok db_1 | creating subdirectories ... ok db_1 | selecting default max_connections ... 100 db_1 | selecting default shared_buffers ... 128MB db_1 | selecting dynamic shared memory implementation ... posix db_1 | creating configuration files ... ok db_1 | running bootstrap script ... ok db_1 | performing post-bootstrap initialization ... ok db_1 | syncing data to disk ... ok db_1 | db_1 | WARNING: enabling "trust" authentication for local connections db_1 | You can change this by editing pg_hba.conf or using the option -A, or db_1 | --auth-local and --auth-host, the next time you run initdb. db_1 | db_1 | Success. You can now start the database server using: db_1 | db_1 | pg_ctl -D /var/lib/postgresql/data -l logfile start db_1 | db_1 | **************************************************** db_1 | WARNING: No password has been set for the database. db_1 | This will allow anyone with access to the db_1 | Postgres port to access your database. In db_1 | Docker's default configuration, this is db_1 | effectively any other container on the same db_1 | system. db_1 | db_1 | Use "-e POSTGRES_PASSWORD=password" to set db_1 | it in "docker run". db_1 | **************************************************** db_1 | waiting for server to start....2019-01-02 08:17:11.952 UTC [41] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432" db_1 | 2019-01-02 08:17:11.958 UTC [42] LOG: database system was shut down at 2019-01-02 08:17:11 UTC db_1 | 2019-01-02 08:17:11.960 UTC [41] LOG: database system is ready to accept connections db_1 | done db_1 | server started db_1 | db_1 | /usr/local/bin/docker-entrypoint.sh: ignoring /docker-entrypoint-initdb.d/* db_1 | db_1 | 2019-01-02 08:17:12.054 UTC [41] LOG: received fast shutdown request db_1 | waiting for server to shut down...2019-01-02 08:17:12.056 UTC [41] LOG: aborting any active transactions db_1 | 2019-01-02 08:17:12.064 UTC [41] LOG: background worker "logical replication launcher" (PID 48) exited with exit code 1 db_1 | 2019-01-02 08:17:12.067 UTC [43] LOG: shutting down db_1 | .2019-01-02 08:17:12.075 UTC [41] LOG: database system is shut down db_1 | done db_1 | server stopped db_1 | db_1 | PostgreSQL init process complete; ready for start up. db_1 | db_1 | 2019-01-02 08:17:12.196 UTC [1] LOG: listening on IPv4 address "0.0.0.0", port 5432 db_1 | 2019-01-02 08:17:12.196 UTC [1] LOG: listening on IPv6 address "::", port 5432 db_1 | 2019-01-02 08:17:12.198 UTC [1] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432" db_1 | 2019-01-02 08:17:12.204 UTC [50] LOG: database system was shut down at 2019-01-02 08:17:12 UTC db_1 | 2019-01-02 08:17:12.206 UTC [1] LOG: database system is ready to accept connections web_1 | Performing system checks... web_1 | web_1 | System check identified no issues (0 silenced). web_1 | web_1 | You have 14 unapplied migration(s). Your project may not work properly until you apply the migrations for app(s): admin, auth, contenttypes, sessions. web_1 | Run 'python manage.py migrate' to apply them. web_1 | January 02, 2019 - 08:20:49 ---
試したこと
使用したハードウェア:
1台目
OS:Windows10Home
DockerType:Dockertoolbox
ターミナル:Docker Quickstart Terminal
2台目
OS:macOS(High Sierra)
DockerType:Dockerformac
ターミナル:ターミナル
ハードウェアを2台使用した理由としてはWindows/MacでOS違いと
DockertoolboxとDockerformacのソフト違いで発生するものか切り分けるためです
結論としては、上記の違いは関係がなさそうでまた他にの箇所で問題が発生しているようです。
上記2台で下記の3つの方法を試しました。
1.Udemy教材(https://www.udemy.com/docker-k/)で学んだ手順です。
・任意の場所でディレクトリを作成 ・そのディレクトリにターミナルのカレントを移動する ・同ディレクトリにDockerfileを作成 --- ソースコード FROM python:3 ENV PYTHONUNBUFFERED 1 RUN mkdir /code WORKDIR /code ADD requirements.txt /code/ RUN pip install -r requirements.txt COPY . /code/ --- ・次にrequirements.txtの作成 --- ソースコード Django==2.0 psycopg2 --- ・最後にdocker-compose.ymlの作成 --- ソースコード version: '3' services: db: image: postgres web: build: . command: python3 manage.py runserver 0.0.0.0:8000 volumes: - .:/code ports: - 8000:8000 depends_on: - db ---
2.DockerのDocker ComposeとDjangoのドキュメント(http://docs.docker.jp/v1.12/compose/django.html)
の手順も試しましたが同様な事象が発生しました
3.すぐ始められる Django on Docker(https://qiita.com/kyon_bll/items/b9b7b8a7f2b1b1767db8)という
Qiita記事で紹介されていた手順を試しましたがこちらも同様な事象が発生しました
補足情報(FW/ツールのバージョンなど)
windows
Docker version 18.03.0-ce, build 0520e24302
docker-compose version 1.20.1, build 5d8c71b2
mac
Docker version 18.09.0, build 4d60db4
docker-compose version 1.23.1, build 1110ad01
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2019/01/06 03:57