docker安装nginx
https://hub.docker.com/
docker search nginx
[root@localhost docker]
REPOSITORY TAG IMAGE ID CREATED SIZE
centos latest 5d0da3dc9764 11 days ago 231MB
[root@localhost docker]
Using default tag: latest
latest: Pulling from library/nginx
07aded7c29c6: Pull complete
bbe0b7acc89c: Pull complete
44ac32b0bba8: Pull complete
91d6e3e593db: Pull complete
8700267f2376: Pull complete
4ce73aa6e9b0: Pull complete
Digest: sha256:06e4235e95299b1d6d595c5ef4c41a9b12641f6683136c18394b858967cd1506
Status: Downloaded newer image for nginx:latest
docker.io/library/nginx:latest
[root@localhost docker]
REPOSITORY TAG IMAGE ID CREATED SIZE
nginx latest f8f4ffc8092c Less than a second ago 133MB
centos latest 5d0da3dc9764 11 days ago 231MB
[root@localhost docker]
[root@localhost docker]
a4bc5fe767b8352e82bea52d1253f76f616e1dd13b134c94e6f9620e5511fd3d
[root@localhost docker]
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
a4bc5fe767b8 nginx "/docker-entrypoint.…" 2 seconds ago Up 1 second 0.0.0.0:3344->80/tcp, :::3344->80/tcp nginx01
2fecd2a6328e centos "/bin/bash -c 'while…" About an hour ago Up About an hour busy_chatelet
[root@localhost docker]
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
html { color-scheme: light dark; }
body { width: 35em; margin: 0 auto;
font-family: Tahoma, Verdana, Arial, sans-serif; }
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p>
<p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p>
<p><em>Thank you for using nginx.</em></p>
</body>
</html>
进入容器查看nginx的配置
# 进入容器查看nginx的配置
[root@localhost docker]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
a4bc5fe767b8 nginx "/docker-entrypoint.…" 9 minutes ago Up 9 minutes 0.0.0.0:3344->80/tcp, :::3344->80/tcp nginx01
2fecd2a6328e centos "/bin/bash -c 'while…" About an hour ago Up About an hour busy_chatelet
[root@localhost docker]# docker exec -it a4bc5fe767b8 /bin/bash
root@a4bc5fe767b8:/# which nginx
/usr/sbin/nginx
root@a4bc5fe767b8:/# whereis nginx
nginx: /usr/sbin/nginx /usr/lib/nginx /etc/nginx /usr/share/nginx
root@a4bc5fe767b8:/# cd /etc/nginx
root@a4bc5fe767b8:/etc/nginx# ls
conf.d fastcgi_params mime.types modules nginx.conf scgi_params uwsgi_params
root@a4bc5fe767b8:/etc/nginx# cat nginx.conf
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log notice;
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;
}
使用volume卷实现容器与宿主机共享文件
|