这篇文章我们主要是了部署我们的领券联盟作准备的
关于docker的安装
这里我们提供两种创建方式
前面我们知道了docker的三要素

接下来我们直接去拉取nginx
我们从远程仓库库拉取Nginx镜像,这个可以搜索一下。当然,我们知道一定有的。
也可以到dockerHub上去搜素


我这就下载完了,如果你下载失败了,多试几次就好。
可以看到,我列出来的镜像就在列表里。
其实可以直接运行的,如果你在运行的时候没有的话,会去拉取。默认不加版本号就是最新的版本。
运行之前,我们先了解一些东西。
所以我们要先创建目录,一个是配置文件目录,一个是测试网页的目录,一个是放置Logs的
mkdir nginx
cd nginx
mkdir conf
mkdir wwwroot
mkdir logs
先在docker目录下创建nginx目录,再创建三个文件夹。
所以,我们的docker run命令这么写:
docker run -d --name=sob-nginx -p 80:80 \
-v /home/aosp/docker/nginx/wwwroot:/usr/share/nginx/html \
-v /home/aosp/docker/nginx/conf/nginx.conf:/etc/nginx/nginx.conf \
-v /home/aosp/docker/nginx/logs:/var/log/nginx \
nginx
说明:
先是准备配置文件,如下最简单的配置
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log /var/log/nginx/host.access.log main;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
}
#error_page 404 /404.html;
# redirect server 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 PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts 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 access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
这是默认的配置
我们直接访问就可以访问到我们的网页啦。

















