docker环境安装
curl -fsSL https://get.docker.com | bash -s docker --mirror Aliyun
拉取最新版本nginx镜像
docker pull nginx:latest
实例化镜像
docker run --name nginx -p 80:80 -v /web/nginx/html:/usr/share/nginx/html -v /web/nginx/conf/nginx.conf:/etc/nginx/nginx.conf -v /web/nginx/log:/var/log/nginx -d nginx
浏览器访问
http://192.168.112.136:8080/
下载php镜像
docker pull php:7.2
生成实例
docker run --name php-test -v /usr/local/www:/www -d php:7.2
nginx.conf配置
server {
listen 80;
server_name localhost;
location / {
root /usr/share/nginx/html;
index index.html index.htm index.php;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
location ~ \.php$ {
fastcgi_pass php:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /www/$fastcgi_script_name;
include fastcgi_params;
}
}
下载mysql镜像
docker pull mysql:5.7
实例化镜像
docker run -itd --name mysql-test -p 3309:3306 -e MYSQL_ROOT_PASSWORD=123456 mysql:5.7
下载redis镜像
docker run -itd --name redis-test -p 6379:6379 redis
实例化redis镜像
docker run -itd --name redis-test -p 6390:6379 redis
进入docker
docker exec -it redis-test /bin/bash
链接redis客户端
redis-cli