I know this question is already asked and also answer given. But it is not working for me. I follow the same. My postgres container is running fine. I checked inside the container that /docker-entrypoint-initdb.d/init.sql exist.I used the following docker-compose.yml.
version: "3"
services:
postgres:
image: postgres:latest
network_mode: bridge
container_name: postgres
expose:
- 5432
ports:
- 5432:5432
volumes:
- ./init.sql:/docker-entrypoint-initdb.d/init.sql
environment:
- POSTGRES_PASSWORD=admin
- POSTGRES_USER=postgres
- POSTGRES_DB=dev
restart: unless-stopped
# APP
profile_editor2:
build:
context: .
dockerfile: ./Dockerfile
network_mode: bridge
container_name: profile_editor2
volumes:
- ./image:/app/image
expose:
- 8080
ports:
- 8080:8080
restart: unless-stopped
depends_on:
- postgres
links:
- postgres
volumes:
postgres-data:
init.sql:-
create table sometable(id int);
No table created. I can see only the database is created. How do I create a table and also if possible insert some data into the table?