root@25fcbf6e953d:/# apt-get install -y vim
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
**安装日志省略。。。。。。。。。。**
然后建立存放静态文件的目录,并创建一个简单的html文件:
root@25fcbf6e953d:/# mkdir -p /var/www/html
root@25fcbf6e953d:/#
root@25fcbf6e953d:/# cd /var/www/html/
root@25fcbf6e953d:/var/www/html# vim index.html
root@25fcbf6e953d:/var/www/html# ll
total 8
drwxr-xr-x. 2 root root 53 Mar 13 05:02 ./
drwxr-xr-x. 3 root root 17 Mar 13 04:50 ../
-rw-r--r--. 1 root root 79 Mar 13 05:02 index.html
-rw-r--r--. 1 root root 612 Mar 13 04:51 index.nginx-debian.html
root@25fcbf6e953d:/var/www/html# cat index.html
<html>
<body>
<h1>
this is the first docker static file
</h1>
</body>
</html>
root@25fcbf6e953d:/var/www/html# 找到nginx的安装目录,更改default的root值为刚才创建的目录:
root@25fcbf6e953d:/var/www/html# whereis nginx
nginx: /usr/sbin/nginx /etc/nginx /usr/share/nginx
root@25fcbf6e953d:/var/www/html# cd /etc/nginx/sites-enabled/
root@25fcbf6e953d:/etc/nginx/sites-enabled# ll
total 4
drwxr-xr-x. 2 root root 20 Mar 13 04:51 ./
drwxr-xr-x. 6 root root 4096 Mar 13 04:51 ../
lrwxrwxrwx. 1 root root 34 Mar 13 04:51 default -> /etc/nginx/sites-available/default
root@25fcbf6e953d:/etc/nginx/sites-enabled# vim default 
然后启动nginx,查看容器进程:
root@25fcbf6e953d:/etc/nginx/sites-enabled# nginx
root@25fcbf6e953d:/etc/nginx/sites-enabled# ps -ef
UID PID PPID C STIME TTY TIME CMD
root 1 0 0 04:48 ? 00:00:00 /bin/bash
root 827 1 0 05:06 ? 00:00:00 nginx: master process nginx
www-data 828 827 0 05:06 ? 00:00:00 nginx: worker process
www-data 829 827 0 05:06 ? 00:00:00 nginx: worker process
www-data 830 827 0 05:06 ? 00:00:00 nginx: worker process
www-data 831 827 0 05:06 ? 00:00:00 nginx: worker process
www-data 832 827 0 05:06 ? 00:00:00 nginx: worker process
www-data 833 827 0 05:06 ? 00:00:00 nginx: worker process
www-data 834 827 0 05:06 ? 00:00:00 nginx: worker process
www-data 835 827 0 05:06 ? 00:00:00 nginx: worker process
root 836 1 0 05:07 ? 00:00:00 ps -ef
root@25fcbf6e953d:/etc/nginx/sites-enabled# 然后按ctrl+p,ctrl+q退出交互式容器。
使用
Docker ps查看容器的端口和运行情况,也可以通过
dcoker port










