Centos7 Docker离线部署nginx
程序员文章站
2022-05-27 16:38:20
...
1 环境信息
查看系统内核
[[email protected] /]# cat /etc/redhat-release
CentOS Linux release 7.5.1804 (Core)
2 虚拟机拉取镜像
此处资源获取在虚拟机中进行,完成后上传到服务器安装
2.1 拉取nginx镜像
[[email protected] /]# docker pull nginx
2.2 导出镜像
[[email protected] /]# docker save -o /opt/module/software/jingxiang/nginx.tar nginx:latest
3 服务器加载镜像
将提供的docker文件夹上传到服务器的 /opt/module/software/jingxiang 目录下
3.1 导入nginx镜像
[[email protected] /]# docker load -i /opt/module/software/jingxiang/nginx.tar
831c5620387f: Loading layer [==================================================>] 72.48 MB/72.48 MB
5fb987d2e54d: Loading layer [==================================================>] 57.67 MB/57.67 MB
4fc1aa8003a3: Loading layer [==================================================>] 3.584 kB/3.584 kB
Loaded image: docker.io/nginx:latest
3.2 创建容器
[[email protected] /]# docker run -p 80:80 --name nginx -d nginx
3.3 映射目录
[[email protected] home]# docker cp -a nginx:/etc/nginx/ /opt/module/env/nginx/conf
[[email protected] home]# docker stop nginx
[[email protected] home]# docker rm nginx
[[email protected] home]# docker run -p 80:80 --privileged=true --restart always --name nginx -v /opt/module/env/nginx/www:/www -v /opt/module/env/nginx/conf/:/etc/nginx/ -v /opt/module/env/nginx/logs:/var/log/nginx -v /opt/module/env/nginx/wwwlogs:/wwwlogs -d nginx
[[email protected] home]# docker restart nginx
3.4 配置nginx
[[email protected] ~]# vi /opt/module/env/nginx/conf/conf.d/default.conf
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log /var/log/nginx/host.access.log main;
location / {
# root /usr/share/nginx/html;
root /home/ftp/;
index index.html index.htm;
}
...
3.5 启动服务
[[email protected] docker]# docker start nginx
3.6 停止服务
[[email protected] docker]# docker stop nginx
3.7 服务信息
服务 nginx
目录 /opt/module/env/nginx/conf/
推荐阅读
-
Docker新手实践及部署NGINX的步骤详解
-
.net core3.0部署Linux服务器 使用Docker容器和Nginx反代理教程
-
Docker CentOS7的系统上安装部署以及基础教程
-
Linux下自动化部署ASP.NET CORE 3.1(Docker+Jenkins+Nginx)
-
CentOS7 Docker Nginx部署及运行详解
-
Linux环境基于CentOS7 搭建部署Docker容器
-
Docker 安装 PHP并与Nginx的部署实例讲解
-
Centos7下,宿主机nginx配合docker环境的php-fpm
-
尝试Docker+Nginx部署单页应用方法
-
docker部署netcore项目 nginx负载均衡