Heim >Backend-Entwicklung >PHP-Tutorial >167 docker docker构建nginx容器系列问题 docker registry docker run docker toolbo
docker构建nginx容器系列问题
background : 最近为小伙伴们筹划docker系列的技术分享,研究了一会docker相关技术, 在此记录一下构建nginx容器时候的坑
1.nginx服务器根目录问题
docker 官方镜像提供的nginx基于debian/jessie平台,其文件结构和ubuntu中的nginx中并不相同
eg:
run一个niginx容器
<code><span>//80端口被占用,so...</span> $ sudo docker run <span>-it</span><span>-p</span><span>800</span>:<span>800</span> nginx $ sudo docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES <span>1801</span>a32aab54 nginx <span>"nginx -g 'daemon off"</span><span>2</span> minutes ago Up <span>2</span> minutes <span>80</span>/tcp, <span>443</span>/tcp, <span>0.0</span><span>.0</span><span>.0</span>:<span>800</span><span>-></span><span>800</span>/tcp berserk_kare</code>
进入容器内部
<code><span>$ </span>sudo docker exec -it <span>1801</span>a32aab54 /bin/bash root<span>@1801a32aab54</span><span>:/</span><span># </span></code>
查看nginx目录
<code><span># cd /etc/nginx/</span> conf<span>.d</span>/ koi-utf mime<span>.types</span> nginx<span>.conf</span> uwsgi_params fastcgi_params koi-win modules/ scgi_params win-utf </code>
可以看到不仅没有熟悉的 /sites-available,也没有 /sites-enabled
继续查看nginx配置
<code><span># cat /conf.d/default.conf</span><span>server</span> { listen <span>80</span>; server_name localhost; <span>#charset koi8-r;</span><span>#access_log /var/log/nginx/log/host.access.log main;</span> location / { root /usr/share/nginx/html; <span>index</span><span>index</span>.html <span>index</span>.htm; } <span>#error_page 404 /404.html;</span><span># redirect server error pages to the static page /50x.html</span><span>#</span> error_page <span>500</span><span>502</span><span>503</span><span>504</span> /<span>50</span>x.html; location = /<span>50</span>x.html { root /usr/share/nginx/html; } <span>#...省略php-fpm配置,好长..</span> }</code>
根目录配置: root /usr/share/nginx/html;
测试
<code><span># cd /usr/share/nginx/html</span><span># touch index.html</span><span># echo "test nginx in docker" >index.html</span></code>
php-fpm配置相关
').addClass('pre-numbering').hide(); $(this).addClass('has-numbering').parent().append($numbering); for (i = 1; i ').text(i)); }; $numbering.fadeIn(1700); }); });以上就介绍了167 docker docker构建nginx容器系列问题,包括了docker,nginx方面的内容,希望对PHP教程有兴趣的朋友有所帮助。