在docker容器中挂载nginx配置文件

时间:2016-05-13 07:50:14

标签: nginx docker

我想将nginx.confdefault.conf挂载到运行nginx的容器中。

docker run --detach --tty --interactive --publish=8081:80 
-v $(pwd)/app:/var/www/ 
-v $(pwd)/configurations/nginx.conf:/etc/nginx/nginx.conf 
-v $(pwd)/configurations/default.conf:/etc/nginx/sites-enabled/default.conf  
--name="my_container" my:dev

我遇到404错误,当我登录docker容器时,我发现app目录已挂载,但default.conf是默认值。

这是default.conf文件:

server {

    root /var/www;
    index index.html index.htm index.php;

    server_name localhost;

    location / {
        try_files $uri $uri/ /index.php?$query_string =404;
    }

    location ~ \.php$ {

                fastcgi_split_path_info ^(.+\.php)(/.+)$;

                fastcgi_pass unix:/run/php/php7.0-fpm.sock;
                fastcgi_index index.php;
                include fastcgi_params;

                fastcgi_buffer_size 128k;
                fastcgi_buffers 256 16k;
                fastcgi_busy_buffers_size 256k;
                fastcgi_temp_file_write_size 256k;
                fastcgi_read_timeout 240;

    }

}

0 个答案:

没有答案