删除docker-ce,docker-ce-cli,containerd.io,重新安装指定版本
curl -sSL https://get.daocloud.io/docker | sh
#(安装指定版本)
sudo yum remove docker-ce docker-ce-cli containerd.io
sudo yum install -y docker-ce-18.09.6-3.el7 docker-ce-cli-18.09.6-3.el7 containerd.io-1.4.6-3.el7
yum info installed containerd.io # 查看正确 containerd.io, 如果不正确则卸载重新安装
sudo curl -L https://github.com/docker/compose/releases/download/1.21.2/docker-compose-$(uname -s)-$(uname -m) -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
新建一个docker-compose.yml
version: '2.0'
services:
nginx:
restart: always
image: nginx:1.17
container_name: work-nginx
ports:
- "8600:8600"
- "8601:80"
volumes:
- ./docker/conf/nginx/nginx.conf:/etc/nginx/nginx.conf
- ./docker/conf/nginx/sites:/etc/nginx/conf.d
- /data:/data
- /data/logs/nginx:/var/log/nginx
networks:
- work-network
hostname: nginx
links:
- php
php:
restart: always
build: ./docker
image: php:7.3-fpm
container_name: work-php
volumes:
- ./docker/conf/php/php.ini:/usr/local/etc/php/php.ini
- ./docker/conf/php/www.conf:/usr/local/etc/php-fpm.d/www.conf
- ./docker/conf/pem:/usr/local/etc/php/pem
- ./docker/conf/supervisor/supervisord.conf:/etc/supervisor/conf.d/supervisord.conf
- /data/logs/supervisor:/var/log/supervisor
- /data:/data
ports:
- "9501:9501"
networks:
- work-network
hostname: php
networks:
work-network:
driver: bridge
在这个文件下运行 docker-compose up -d
即安装完成
注:
#安装php 扩展
/usr/bin/docker exec -i work-php pecl install swoole && docker-php-ext-enable swoole
#或者
docker-php-ext-install pdo pdo_mysql
#或者
/usr/bin/docker exec -i work-php docker-php-ext-install -j$(nproc) swoole
docker pull mysql:5.7
docker run -p 3306:3306 --name work-mysql -v /root/mysql/conf:/etc/mysql/conf.d -v /root/mysql/logs:/logs -v /root/mysql/data:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=root -d mysql:5.7
彻底解决sql_mode=only_full_group_by
SELECT @@sql_mode;
SET @@global.sql_mode ='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';
SET sql_mode ='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';
flush privileges;
也可以在 /etc/my.cnf添加如下列:
[mysqld]
sql_mode=NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
docker pull redis
docker run -itd --name work-redis -p 6379:6379 redis
全部安装完成