A series of problems with docker building nginx containers
Background: I recently planned a technology sharing of the docker series for my friends. After studying docker related technologies for a while, I will record the pitfalls when building nginx containers
1.nginx server root directory Problem
Docker official image provides nginx based on debian/jessie platform, its file structure is different from nginx in ubuntu
eg:
run a niginx container
<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>
Enter the container
<code><span>$ </span>sudo docker exec -it <span>1801</span>a32aab54 /bin/bash root<span>@1801a32aab54</span><span>:/</span><span># </span></code>
View nginx Directory
<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>
You can see that there is not only the familiar /sites-available, but also no /sites-enabled
Continue to view the nginx configuration
<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 directory configuration: root /usr/share/nginx/html;
Test
<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 configuration related
').addClass('pre-numbering').hide(); $(this).addClass('has-numbering').parent().append($numbering); for (i = 1; i ').text(i)); }; $numbering.fadeIn(1700); }); });The above introduces the 167 docker docker series of problems in building nginx containers, including docker and nginx content. I hope it will be helpful to friends who are interested in PHP tutorials.