Æô¶¯Ò»¸öÈÝÆ÷ÔËÐÐnginx:
[root@node121 ~]# docker search nginx
NAME DESCRIPTION STARS OFFICIAL AUTOMATED
nginx Official build of Nginx. 4927 [OK]
jwilder/nginx-proxy Automated Nginx reverse proxy for docker c... 901 [OK]
ÏÂÔØ nginx¾µÏñ£º
[root@node121 ~]# docker pull nginx
latest: Pulling from nginx
32734c6d04f6: Pull complete
1849b6667515: Pull complete
dd624ca8e781: Pull complete
9fc8fc300550: Pull complete
590494f17750: Pull complete
943e2fd86162: Pull complete
cd021197146a: Pull complete
93c50d378b4b: Pull complete
Digest:sha256:2b942f7dd01a57ceeb5985a0472a2f92735eb81a910dec70c2183c61fc54298c
Status: Downloaded newer image for nginx:latest
[root@node121 ~]# docker images
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
nginx latest 93c50d378b4b 2 daysago 181.6 MB
centos latest d4350798c2ee 2 weeksago 191.8 MB
ÔËÐÐnginx
[root@node121 ~]# docker run -d --name mynginx nginx
5df8eb0d89ad9785854fe0abd1d5b9d25917bb270d214a5450d9aae899276bf1
#docker ps -a | grep nginx
½øÈëÒ»¸öÒÑÔËÐеÄÈÝÆ÷Àï:
»ñÈ¡Ò»¸öÈÝÆ÷µÄPID
#docker inspect --format "{{.State.Pid}}" mynginx
32439
yum install util-linux
#nsenter --target32439 --mount --uts --ipc --net --pid #½øÈëÈÝÆ÷µÄÁíÒ»ÖÖ·½·¨
ÔÚdockerÖеÄnginxÅäÖÃĿ¼£º
cd /etc/nginx/nginx.conf
¸ùĿ¼£º
/usr/share/nginx/html
nginxÅäÖÃĿ¼;
cat /etc/nginx/conf.d/default.conf
rootĿ¼£º/usr/share/nginx/html;
root@5df8eb0d89ad:/etc/nginx# cat /etc/nginx/nginx.conf
user nginx;
worker_processes 1;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
#tcp_nopush on;
keepalive_timeout 65;
#gzip on;
include /etc/nginx/conf.d/*.conf; #ÅäÖÃÎļþĿ¼
}
root@5df8eb0d89ad:/etc/nginx/conf.d# cat/etc/nginx/conf.d/default.conf
server {
listen 80;
server_name localhost;
#charsetkoi8-r;
#access_log /var/log/nginx/log/host.access.log main;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
}
#error_page 404 /404.html;
# redirectserver 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 PHPscripts to Apache listening on 127.0.0.1:80
#
#location ~\.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHPscripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~\.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}
# deny accessto .htaccess files, if Apache's document root
# concurs withnginx's one
#
#location ~/\.ht {
# deny all;
#}
}