Hello,
I have made a docker-compose which is creating an image for a Postgres database and PGAdmin. This is working fine.
Now I want to extend the Docker-compose.yml with a Dockerfile-db which should copy files. It is not copied, so I made one step back, only echoing text.
This is docker-compose.yml for PostgreSQL:
version: '3.8'
services:
postgres_db:
image: postgis/postgis:14-master
ports:
- "5432:5432" # -p
container_name: yyyy # --name
build:
context: .
dockerfile: Dockerfile-db
restart: always
environment:
POSTGRES_DB: xxxxx
POSTGRES_USER: xxxx
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
env_file:
- .env
networks:
- pg-network
volumes:
- ./aaaa_container_db-data/:/var/lib/postgresql/data/ # -v
- ./aaaa_container_tmp_data:/tmp
- ./init-multi-postgres-databases.sh:/docker-entrypoint-initdb.d/init-multi-postgres-databases.sh
healthcheck:
test: [ "CMD-SHELL", "pg_isready -h localhost -U $$POSTGRES_USER" ]
interval: 15s
timeout: 10s
retries: 12
# here the PgAdmin
#...
#...
networks:
pg-network:
driver: bridge
volumes:
aaaa_container_db-data:
This is my Dockerfile (is in the same directory as the Docker-compose.yml):
FROM postgis/postgis:14-master
CMD ["echo", "Starting the container..."]
I expect the text āStarting the containerā¦ā in container log, but I donāt see it, which I donāt understand.
- I develop with Windows 11 (IntelliJ). The files as Docker-compose.yml,
- Dockerfile-db have āLFā as carriage return.
- If I understand it right,RUN āStarting the containerā¦ā is excuted at time of building the image
- and CMD [āechoā, āStarting the containerā¦ā] at the time of running the container.
Has somebody an idea what I do wrong? Or is there another possibillity to verify if the Dockerfile-db is executed?