Created
January 29, 2020 08:05
-
-
Save nicolas-zozol/04f2efcc3d6fd4028a9f02a80d69e73d to your computer and use it in GitHub Desktop.
Adminer + Postgres docker-compose
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
version: "3.3" | |
services: | |
# POSTGRES: https://github.com/docker-library/postgres | |
db: | |
image: postgres | |
container_name: db | |
#restart: always | |
environment: | |
POSTGRES_USER: ${POSTGRES_USER} | |
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD} | |
# exposes 5432 | |
networks: ["stack"] | |
ports: ["5432:5432"] | |
volumes: | |
- db-data:/var/lib/postgresql/data | |
- db-conf:/etc/postgresql | |
adminer: | |
container_name: adminer | |
image: adminer | |
#restart: always | |
ports: | |
- 8080:8080 | |
networks: ["stack"] | |
# Needed for windows. Might be better to uncomment on linux/prod ; check for local | |
volumes: | |
db-data: | |
driver: local | |
db-conf: | |
driver: local |
MySql is sometimes already used by ubuntu system and difficult/unwanted to remove. In that case change local port, but not the docker one
ports: ["6306:3306"]
In that case, your code will make SQL queries to 6306 port on your computer, but it will be transferred to the 3306 on docker container.
It's a hack for quick test, not recommanded as you will quickly diverge from a prod environment.
SQLSTATE[08006] [7] connection to server at "127.0.0.1", port 5432 failed: Connection refused Is the server running on that host and accepting TCP/IP connections?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
simplified version: