mysql打包成docker_web应用如何打包成docker镜像?

用docker-compose组织吧,类似这种

version: '3.7'

x-logging: &default-logging

driver: "json-file"

options:

max-size: "20m"

max-file: "10"

services:

### Nginx container ##########################################################

nginx:

image: nginx

ports:

- "80:80"

- "443:443"

volumes:

- wwwroot:/var/www/html:ro

- ./work/nginx/entrypoint.conf:/etc/nginx/nginx.conf:ro

- ./work/nginx:/etc/nginx/conf.d:ro

- ./work/logs:/var/log/nginx:rw

- /etc/localtime:/etc/localtime:ro

restart: always

container_name: nginx

depends_on:

- mysql

- redis

logging: *default-logging

### PHP-FPM container ########################################################

php-fpm:

image: php7.3-fpm

volumes:

- wwwroot:/var/www/html:rw

- ./work/php/php.ini:/usr/local/etc/php/php.ini:ro

- ./work/php/php-fpm.conf:/usr/local/etc/php-fpm.d/www.conf:ro

- ./work/logs:/var/log:rw

- /etc/localtime:/etc/localtime:ro

privileged: false

container_name: php-fpm

logging: *default-logging

### Mysql container ##########################################################

mysql:

image: mysql:5.7

ports:

- "127.0.0.1:3306:3306/tcp"

secrets:

- db_root_password

- db_password

volumes:

- mysqldata:/var/lib/mysql:rw

- ./work/mysql/mysql.cnf:/etc/mysql/my.cnf:ro

- ./work/logs:/var/log/mysql:rw

- /etc/localtime:/etc/localtime:ro

restart: always

container_name: mysql

environment:

MYSQL_USER: ${MYSQL_USER}

MYSQL_DATABASE: ${MYSQL_DATABASE}

MYSQL_ROOT_PASSWORD_FILE: /run/secrets/db_root_password

MYSQL_PASSWORD_FILE: /run/secrets/db_password

logging: *default-logging

### Redis container ##########################################################

redis:

image: redis:5.0

entrypoint:

- redis-server

- /usr/local/etc/redis/redis.conf

volumes:

- ./work/redis/redis.conf:/usr/local/etc/redis/redis.conf:ro

- ./work/logs:/var/log/redis:rw

- /etc/localtime:/etc/localtime:ro

restart: always

container_name: redis

logging: *default-logging

volumes:

wwwroot:

mysqldata:

secrets:

db_root_password:

file: ./db_root_password.txt

db_password:

file: ./db_${MYSQL_USER}_password.txt

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值