Skip to content

Instantly share code, notes, and snippets.

@nicolas-zozol
Created January 29, 2020 08:05
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nicolas-zozol/04f2efcc3d6fd4028a9f02a80d69e73d to your computer and use it in GitHub Desktop.
Save nicolas-zozol/04f2efcc3d6fd4028a9f02a80d69e73d to your computer and use it in GitHub Desktop.
Adminer + Postgres docker-compose
---
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
@nicolas-zozol
Copy link
Author

nicolas-zozol commented Apr 29, 2021

simplified version:

---
version: "3.3"
services:
  # POSTGRES: https://github.com/docker-library/postgres
  pg:
    image: postgres
    container_name: pg
    #restart: always
    environment:
      POSTGRES_USER: ${POSTGRES_USER}
      POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
      POSTGRES_DB: robusta_pg
    # exposes 5432
    ports: ["5432:5432"]

  my:
    image: mysql:8.0.3
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: ${MYSQL_PASSWORD}
      MYSQL_DATABASE: robusta
    ports: ["3306:3306"]

  adminer:
    container_name: adminer
    image: adminer
    #restart: always
    ports:
      - 8080:8080

@nicolas-zozol
Copy link
Author

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.

@pluveto
Copy link

pluveto commented Feb 25, 2022

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