docker|docker compose

version: "3" networks: overnet: name: overnet attachable: true services: jenkins: image: "jenkins/jenkins:2.303.3" restart: always ports: - 8080:8080 networks: - overnet volumes: - /data/jenkins_home:/var/jenkins_home mysql: image: "mysql:5.7.31" restart: always ports: - 3306:3306 networks: - overnet environment: MYSQL_ROOT_PASSWORD: "123456789" command: [ '--character-set-server=utf8mb4', '--collation-server=utf8mb4_general_ci', '--max_connections=3000' ] volumes: - /data/mysql/initdb.d:/docker-entrypoint-initdb.d - /data/mysql/log:/var/log/mysql - /data/mysql/conf:/etc/mysql/conf.d - /data/mysql/data:/var/lib/mysql psql_db: image: "postgres:13-alpine" restart: always ports: - 5432:5432 environment: - POSTGRES_PASSWORD=123456789 networks: - overnet volumes: - /data/postgres/initdb.d:/docker-entrypoint-initdb.d - /data/postgres/postgresql.conf:/etc/postgresql/postgresql.conf - /data/postgres/data:/var/lib/postgresql/data redis: image: redis restart: always ports: - 6379:6379 networks: - overnet volumes: - /data/redis/conf:/etc/redis command: ["redis-server", "/etc/redis/redis.conf"] mongo: image: mongo restart: always ports: - 27017:27017 networks: - overnet volumes: - /data/mongo/db:/data/db nginx: container_name: nginx-master image: nginx restart: always ports: - 80:80 - 443:443 networks: - overnet extra_hosts: - host.docker.internal:192.168.0.16 volumes: - /data/nginx/nginx.conf:/etc/nginx/nginx.conf - /data/nginx/conf.d:/etc/nginx/conf.d - /data/nginx/sites-available:/etc/nginx/sites-available - /data/nginx/sites-enabled:/etc/nginx/sites-enabled - /data/www/serve:/usr/share/nginx/html - /data/nginx/cert:/etc/nginx/cert

init 文件
  • /data/mysql/initdb.d/init.sh
#!/bin/bashmysql --protocol=socket -uroot -p$MYSQL_ROOT_PASSWORD <

  • /data/postgres/initdb.d/init.sh
#!/bin/bash set -epsql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" <<-EOSQL create user test_user with password '123456'; create DATABASE test ENCODING='UTF8' owner test_user; grant all privileges on database test to test_user; EOSQL

    推荐阅读