Docker using compose, configuration file with environment variables and creating a container, in addition the data are present on the local machine even after restart or re created the container :
- postgres:12
-
Expose port
- 5432
-
Volume (Note: check if in the docker configuration -> shared drivers, the units are enabled)
- Application database: ./docker/postgres/data -> /var/lib/postgresql/data
- Automatically create schema: ./docker/schema.sql -> /docker-entrypoint-initdb.d/0.schema.sql
- Clone the repository using the command:
$ git clone https://github.com/jadilson12/docker-compose-postgres
- Enter the folder docker-compose-postgres copy the files
$ cp env-example .env
$ cp docker-compose.yml-example docker-compose.yml
- Run your container:
$ docker-compose up -d
- Access the container shell:
$ docker exec -it app-database sh
Contributions, issues and feature requests are welcome!
Feel free to check issues page.
Give a ⭐️ if this project helped you!
Jadilson Guedes jadilson12@gmail.com
License MIT https://jadilson12.mit-license.org/