docker

作者: IT宝哥哥 | 来源:发表于2019-11-03 10:22 被阅读0次
  1. 创建容器
docker run --name mynginx -p 80:80 --network mybridge -v /etc/nginx/conf.d:/etc/nginc/conf.d:ro -v /var/www:/usr/share/nginx/html:ro -d nginx

--network 将该容器加入到指定的网络中,也可以后期指定:docker network connect mybridge mynginx
:ro readonly

docker run --name myphpfpm -p 9000:9000 --network mybridge -v /var/www:/var/www:ro -d php:7.3-fpm
docker run --name mydb -p 3306:3306 --network mybridge -e MYSQL_ROOT_PASSWORD=123456 -d mysql:5.7

-e 指定环境变量

  1. 修改nginx配置
/default.conf
server {
    listen       80;
    server_name  localhost;

    #charset koi8-r;
    #access_log  /var/log/nginx/host.access.log  main;
    root /usr/share/nginx/html;#这里是document_roo配置
    location / {
        #root   /usr/share/nginx/html;
        index  index.html index.htm;
        #proxy_pass http://127.0.0.1:8080;#反向代理设置
    }
    
    #error_page  404              /404.html;
    
    # redirect server error pages to the static page /50x.html
    #
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/share/nginx/html;
    }
    
    # proxy the PHP scripts to Apache listening on 127.0.0.1:80
    #
    #location ~ \.php$ {
    #   proxy_pass   php:9000;
   #}

    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    #
    location ~ \.php$ {
        #root          html;#默认设置路径
        fastcgi_pass   172.18.0.4:9000;#对应php-fpm的ip和端口
        fastcgi_index  index.php;
        #fastcgi_param  SCRIPT_FILENAME /scripts$fastcgi_script_name;#默认配置
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;#这里的document_root,就是location中root的设置
        include        fastcgi_params;
    }
    
    # deny access to .htaccess files, if Apache's document root
    # concurs with nginx's one
    #
    #location ~ /\.ht {
    #    deny  all;
    #}
}

相关文章

  • docker学习

    docker镜像 docker容器 docker仓库 安装docker docker版本 docker分为社区版和...

  • Docker安装和运行

    获取Docker 安装Docker 验证安装 1、获取Docker Docker for Mac Docker f...

  • Docker知识手册

    Docker 容器 启动docker:docker start 查看docker运行状态:docker stats...

  • Docker简介

    章节介绍 # Docker是什么# Docker包括什么# Docker镜像# Docker编配# Docker还...

  • Docker 常用操作

    Docker docker: 18.09.4、nvidia-docker: 2.0.3 docker 19.03 ...

  • rancher+harbor离线安装

    安装docker,此docker为社区版docker。docker官方文档:https://docs.docker...

  • Linux之Docker

    Linux之Docker 目录 Docker简单介绍 在线Docker安装 离线Docker安装 Docker简单...

  • Docker常用命令

    Docker常用命令 Docker帮助命令 docker version:查看docker版本 docker in...

  • Docker基础操作

    Docker部署 Docker安装 镜像加速 Docker 基础命令 Docker镜像管理 搜索镜像docker ...

  • docker容器状态查看命令集

    docker inspect 用法 : docker inspect [docker名称/docker short...

网友评论

      本文标题:docker

      本文链接:https://www.haomeiwen.com/subject/rxisyctx.html