Reputation: 310
I am trying to build a service based on postgresql using docker-compose.
The service is very simple:
version: "3.8"
services:
db:
image: postgres:latest
volumes:
- db-data:/var/lib/postgresql/data
deploy:
restart_policy:
condition: on-failure
delay: 5s
max_attempts: 3
window: 120s
volumes:
db-data:
The problem I am facing is due to the postgresl image that does not start due to the absence of root password.
When I build the container using docker run, I can pass arguments to the default command using the flag '-e' and set the root password.
I would like to do the same but directly in the compose file in order to have the root password set the first time the service is created but not executed in the subsequent run which will not need to build the image again.
I was hoping to find an option under the "build" tag of the compose file but to no avail.
The aim is to have the deployment process as smooth as possible without having to connect to the container afterwards to set the root password.
Upvotes: 0
Views: 149
Reputation:
the official postgres image has several environment variables you can use to configure the service, including the one you're looking for.
Check its documentation at https://hub.docker.com/_/postgres
Upvotes: 1