I wish to expand a web-application using docker (I'm beginner in Docker). My application demands PostgreSQL. Therefore I decided to use the docker-compose.
The docker-compose.yaml looks like:
version: '3.8'
services:
db:
image: postgres
command: "postgres -c listen_addresses='*'"
environment:
- POSTGRES_DB=CatsQMS
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=12345qwerty
application:
build: .
ports:
- "8080:8080"
depends_on:
- db
Also I have the file config.yaml which configures my web-application, it looks like this:
database_config:
host: db
user: postgres
password: 12345qwerty
port: 5432
database: CatsQMS
# Unimportant stuff
And when I lunch the docker-compose, using docker-compose up the build is freezing at this point:
Recreating cats_queue_management_system_db_1 ... done
Recreating cats_queue_management_system_application_1 ... done
Attaching to cats_queue_management_system_db_1, cats_queue_management_system_application_1
db_1 |
db_1 | PostgreSQL Database directory appears to contain a database; Skipping initialization
db_1 |
db_1 | 2020-05-20 13:42:51.628 UTC [1] LOG: starting PostgreSQL 12.3 (Debian 12.3-1.pgdg100+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 8.3.0-6) 8.3.0, 64-bit
db_1 | 2020-05-20 13:42:51.628 UTC [1] LOG: listening on IPv4 address "0.0.0.0", port 5432
db_1 | 2020-05-20 13:42:51.628 UTC [1] LOG: listening on IPv6 address "::", port 5432
db_1 | 2020-05-20 13:42:51.635 UTC [1] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
db_1 | 2020-05-20 13:42:51.660 UTC [24] LOG: database system was shut down at 2020-05-20 13:39:45 UTC
db_1 | 2020-05-20 13:42:51.673 UTC [1] LOG: database system is ready to accept connections
Perhaps it's an important thing, my Dockerfile:
FROM python:3.8
RUN mkdir /docker-entrypoint-initdb.d/
COPY ./application/sources/database/init.sql /docker-entrypoint-initdb.d/
RUN mkdir /app
WORKDIR /app
COPY . /app
RUN pip install -r requirements.txt
RUN python3 setup.py develop
ENTRYPOINT ["start_app", "-d"]
Where have I admitted a mistake?
Your application and PostgreSQL database are running and should work as expected. But Docker attached after running the containers to the db container.
You can avoid this by using the option -d or --detach on docker-compose up:
The
docker-compose upcommand aggregates the output of each container (essentially runningdocker-compose logs -f). When the command exits, all containers are stopped. Runningdocker-compose up -dstarts the containers in the background and leaves them running.
So your command looks like this:
docker-compose up -d
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With