前言
记录一下 Docker compose 安装 PostgreSQL 和 MySQL。
PostgreSQL
docker-compose 配置
1 2 3 4 5 6 7 8 9 10 11 12 13 14
| version: "3"
postgres: image: postgres container_name: local_postgresql restart: always environment: POSTGRES_DB: db_name POSTGRES_USER: postgres POSTGRES_PASSWORD: password ports: - 4352:5432 volumes: - /data/postgresql:/var/lib/postgresql/data
|
MySQL
docker-compose 配置
1 2 3 4 5 6 7 8 9 10 11 12 13
| version: '3' services: mysql: image: mysql container_name: local_mysql entrypoint: ['/entrypoint.sh', '--default-authentication-plugin=mysql_native_password'] restart: always volumes: - /data/mysql:/var/lib/mysql/ ports: - 127.0.0.1:3306:3306 environment: - MYSQL_ROOT_PASSWORD=password
|
启动
参考
- https://blog.windrunner.me/sa/dockerize-postgres.html
- https://yeasy.gitbooks.io/docker_practice/install/ubuntu.html
- https://docs.docker.com/v17.09/engine/installation/linux/docker-ce/ubuntu/#set-up-the-repository