Closed davidcr01 closed 1 year ago
To perform this task, I have researched some documentation and tutorial that may help:
Besides, the first link builds a dockerized project using Angular
as the frontend, so maybe it would be useful in the future to dockerize the backend, but using Ionic Framework instead.
While following the tutorial, I faced several problems.
:red_circle: After configuring the Django API and the PostgreSQL database, I got the error: Error Could not translate host name "db" to address: Name or service not known
This error was displayed after executing the docker compose up
command. After searching some related problems, and trying some proposed solutions in this post, the error kept displaying.
:heavy_checkmark: The solution that fixed the problem was related to the initialization of the database. Following the second tutorial, adding the `POSTGRES*` environment variables.
environment:
- POSTGRES_DB=postgres
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=postgres
The log of the docker compose
command is:
> docker compose up
[+] Running 2/0
⠿ Container wordle-db-1 Created 0.0s
⠿ Container dj Crea... 0.0s
Attaching to dj, wordle-db-1
wordle-db-1 |
wordle-db-1 | PostgreSQL Database directory appears to contain a database; Skipping initialization
wordle-db-1 |
wordle-db-1 | 2023-02-11 17:56:23.618 UTC [1] LOG: starting PostgreSQL 15.1 (Debian 15.1-1.pgdg110+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 10.2.1-6) 10.2.1 20210110, 64-bit
wordle-db-1 | 2023-02-11 17:56:23.618 UTC [1] LOG: listening on IPv4 address "0.0.0.0", port 5432
wordle-db-1 | 2023-02-11 17:56:23.618 UTC [1] LOG: listening on IPv6 address "::", port 5432
wordle-db-1 | 2023-02-11 17:56:23.638 UTC [1] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
wordle-db-1 | 2023-02-11 17:56:23.652 UTC [29] LOG: database system was shut down at 2023-02-11 17:19:38 UTC
wordle-db-1 | 2023-02-11 17:56:23.666 UTC [1] LOG: database system is ready to accept connections
dj | Watching for file changes with StatReloader
dj | Performing system checks...
dj |
dj | System check identified no issues (0 silenced).
dj | February 11, 2023 - 17:56:24
dj | Django version 4.1.6, using settings 'djangoproject.settings'
dj | Starting development server at http://0.0.0.0:80/
dj | Quit the server with CONTROL-C.
If I navigate to https://localhost:80
the Django welcome page is displayed:
This issue aims to build a dockerized project.
It is necessary to dockerize the backend of the application. This concerns: