Redis+Mysql+Mongo
镜像:
docker pull redis:6.0
docker pull mysql:5.7
docker pull mongo:4.2
容器:
Redis:
docker run -d --name redis6 -p 6379:6379 --restart always redis:6.0
Mysql:
docker run --name mysql57 -e MYSQL_ROOT_PASSWORD=123456 -d -p 3306:3306 \--restart always mysql:5.7
Mysql远程连接:(docker安装的mysql默认密码是123456)
登录到容器,登录到Mysql。
alter user 'root'@'%' identified with mysql\_native\_password by '123456';flush privileges;
Mongo:
docker run --name mongo42 -d -p 27017:27017 --restart always mongo:4.2
Nginx + PHP-FPM
PHP-FPM
镜像
docker pull php:7.4-fpm
容器
docker run -d -v /www/wwwroot:/usr/share/nginx/html --name php7.4 php:7.4-fpm
Nginx:
docker run --name mynginx -v /www/wwwroot:/usr/share/nginx/html:ro -p 8080:80 --link php7.4:php7.4 -d nginx
登录到nginx容器:
docker exec - it mynginx bashcd / etc / nginx / conf.dmv default.conf default.conf.bak( default.conf占用了80端口) apt updateapt install vim - yvim / etc / nginx / conf.d / test.conf
切换粘贴模式:
set mouse -= aserver { listen 80; server_name localhost; location / { root / usr / share / nginx / html; index index.html index.htm index.php; try_files $uri $uri / /index.php$is_args$query_string; } location ~ \.php$ { fastcgi_pass php7.4:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME /usr / share / nginx / html / $fastcgi_script_name; include fastcgi_params; } }
注意:
由于Nginx与PHP-FPM不在同一台服务器,这里两个容器运行时指定的-v参数需要保持一致:
-v /www/wwwroot:/usr/share/nginx/html