У меня и моей команды возникают некоторые проблемы, когда мы пытаемся поместить наш проект Python в localhost.
Когда мы попадаем в PowerShell и набираем "docker-compose up
", мы получаем следующий журнал:
(myvenv) PS D:\GitHub\lux_pecuaria\workspace> docker-compose up
Creating network "workspace_default" with the default driver
Creating workspace_pecuaria_db_1 ... done
Creating workspace_pecuaria_web_1 ... done
Attaching to workspace_pecuaria_db_1, workspace_pecuaria_web_1
pecuaria_db_1 | The files belonging to this database system will be owned by user "postgres".
pecuaria_db_1 | This user must also own the server process.
pecuaria_db_1 |
pecuaria_db_1 | The database cluster will be initialized with locale "en_US.utf8".
pecuaria_db_1 | The default database encoding has accordingly been set to "UTF8".
pecuaria_db_1 | The default text search configuration will be set to "english".
pecuaria_db_1 |
pecuaria_db_1 | Data page checksums are disabled.
pecuaria_db_1 |
pecuaria_db_1 | fixing permissions on existing directory /var/lib/postgresql/data ... ok
pecuaria_db_1 | creating subdirectories ... ok
pecuaria_db_1 | selecting default max_connections ... 100
pecuaria_db_1 | selecting default shared_buffers ... 128MB
pecuaria_db_1 | selecting dynamic shared memory implementation ... posix
pecuaria_db_1 | creating configuration files ... ok
pecuaria_db_1 | running bootstrap script ... ok
pecuaria_web_1 | Performing system checks...
pecuaria_web_1 |
pecuaria_web_1 | System check identified no issues (0 silenced).
pecuaria_web_1 | October 15, 2018 - 14:53:02
pecuaria_db_1 | performing post-bootstrap initialization ... ok
pecuaria_db_1 | syncing data to disk ... ok
pecuaria_db_1 |
pecuaria_db_1 | WARNING: enabling "trust" authentication for local connections
pecuaria_db_1 | You can change this by editing pg_hba.conf or using the option -A, or
pecuaria_db_1 | --auth-local and --auth-host, the next time you run initdb.
pecuaria_db_1 |
pecuaria_db_1 | Success. You can now start the database server using:
pecuaria_db_1 |
pecuaria_db_1 | pg_ctl -D /var/lib/postgresql/data -l logfile start
pecuaria_db_1 |
pecuaria_db_1 | ****************************************************
pecuaria_db_1 | WARNING: No password has been set for the database.
pecuaria_db_1 | This will allow anyone with access to the
pecuaria_db_1 | Postgres port to access your database. In
pecuaria_db_1 | Docker's default configuration, this is
pecuaria_db_1 | effectively any other container on the same
pecuaria_db_1 | system.
pecuaria_db_1 |
pecuaria_db_1 | Use "-e POSTGRES_PASSWORD=password" to set
pecuaria_db_1 | it in "docker run".
pecuaria_db_1 | ****************************************************
pecuaria_db_1 | waiting for server to start....2018-10-15 14:53:27.630 UTC [40] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
pecuaria_db_1 | 2018-10-15 14:53:27.861 UTC [41] LOG: database system was shut down at 2018-10-15 14:52:59 UTC
pecuaria_db_1 | 2018-10-15 14:53:27.947 UTC [40] LOG: database system is ready to accept connections
pecuaria_db_1 | done
pecuaria_db_1 | server started
pecuaria_db_1 |
pecuaria_db_1 | /usr/local/bin/docker-entrypoint.sh: ignoring /docker-entrypoint-initdb.d/*
pecuaria_db_1 |
pecuaria_db_1 | waiting for server to shut down....2018-10-15 14:53:28.003 UTC [40] LOG: received fast shutdown request
pecuaria_db_1 | 2018-10-15 14:53:28.077 UTC [40] LOG: aborting any active transactions
pecuaria_db_1 | 2018-10-15 14:53:28.081 UTC [40] LOG: worker process: logical replication launcher (PID 47) exited with exit code 1
pecuaria_db_1 | 2018-10-15 14:53:28.089 UTC [42] LOG: shutting down
pecuaria_db_1 | 2018-10-15 14:53:28.464 UTC [40] LOG: database system is shut down
pecuaria_db_1 | done
pecuaria_db_1 | server stopped
pecuaria_db_1 |
pecuaria_db_1 | PostgreSQL init process complete; ready for start up.
pecuaria_db_1 |
pecuaria_db_1 | 2018-10-15 14:53:28.643 UTC [1] LOG: listening on IPv4 address "0.0.0.0", port 5432
pecuaria_db_1 | 2018-10-15 14:53:28.643 UTC [1] LOG: listening on IPv6 address "::", port 5432
pecuaria_db_1 | 2018-10-15 14:53:28.763 UTC [1] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
pecuaria_db_1 | 2018-10-15 14:53:28.923 UTC [49] LOG: database system was shut down at 2018-10-15 14:53:28 UTC
И мы не получаем доступа к http://localhost:8000. Это говорит о том, что в Chrome было отказано в соединении.
Это наш docker_compose.yml
:
version: "3"
services:
pecuaria_db:
image: postgres
build:
context: .
dockerfile: Dockerfile-db
ports:
- "5432:5432"
pecuaria_web:
build:
context: .
dockerfile: Dockerfile-web
command: python3 manage.py runserver 0.0.0.0:8000
volumes:
- .:/code
ports:
- "8000:8000"
depends_on:
- pecuaria_db
Это наш Dockerfile-db
:
FROM postgres
ENV POSTGRES_DB pecuaria
ENV POSTGRES_USER luxpecu
ENV POSTGRES_PASSWORD @nimalux!
EXPOSE 5432
Это наш Dockerfile-web
FROM python:3
ENV PYTHONUNBUFFERED 1
RUN mkdir /code
WORKDIR /code
ADD requirements.txt /code/
RUN pip install -r requirements.txt
ADD . /code/
И это наш setting.py в БАЗАХ ДАННЫХ:
'default':{
'ENGINE': 'django.db.backends.postgresql',
'NAME': 'pecuaria',
'USER': 'luxpecu',
'PASSWORD': '@nimalux!',
'HOST': 'pecuaria_db',
'PORT': 5432
}
Пожалуйста, что мы делаем не так?Спасибо.