Skip to content

常用docker-compose-yml

🕒 Posted at: 2020-07-01 ( 4 years ago )
dockerdocker-compose
常用docker-compose-yml

MySQL

.env

txt
MYSQLIMAGE=mysql:8
MYSQLPORTEXPOSE=3306
MYSQLROOT_PASSWORD=gitea
yml
version: "3.3"

networks:
  mysql:
    external: false
    name: mysql_net
services:
  mysql:
    container_name: local_mysql
    image: ${MYSQL_IMAGE}
    restart: always
    environment:
      - MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD}
    networks:
      - mysql
    ports:
      - "${MYSQL_PORT_EXPOSE}:3306"
    volumes:
      - ./mysql:/var/lib/mysql

PostgreSQL

yaml
version: "3.3"

networks:
  postgres_net:
    external: false
    name: postgres_net
services:
  postgres_db:
    image: postgres:13
    restart: always
    container_name: postgres
    environment:
      - POSTGRES_USER=root
      - POSTGRES_PASSWORD=
      - POSTGRES_DB=
    networks:
      - postgres_net
    ports:
      - "5432:5432"
    volumes:
      - ./postgres:/var/lib/postgresql/data

Redis

yaml
version: '3.1'

services:
  redis:
    image: redis:latest
    ports:
      - "6379:6379"
    volumes:
      - ./redis:/data
    command: redis-server --appendonly yes --requirepass yourpassword
    environment:
      REDIS_PASSWORD: "yourpassword"
Copyright © RyChen 2024