首页 > 系统相关 >云原生之使用docker部署nginx网站

云原生之使用docker部署nginx网站

时间:2023-06-13 13:01:14浏览次数:59  
标签:原生 container ip nginx host docker port

(云原生之使用docker部署nginx网站)

一、检查本地系统版本

[root@node ~]# cat /etc/os-release 
NAME="CentOS Linux"
VERSION="7 (Core)"
ID="centos"
ID_LIKE="rhel fedora"
VERSION_ID="7"
PRETTY_NAME="CentOS Linux 7 (Core)"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:centos:centos:7"
HOME_URL="https://www.centos.org/"
BUG_REPORT_URL="https://bugs.centos.org/"

CENTOS_MANTISBT_PROJECT="CentOS-7"
CENTOS_MANTISBT_PROJECT_VERSION="7"
REDHAT_SUPPORT_PRODUCT="centos"
REDHAT_SUPPORT_PRODUCT_VERSION="7"

二、检查docker状态

[root@node ~]# systemctl status docker
● docker.service - Docker Application Container Engine
   Loaded: loaded (/usr/lib/systemd/system/docker.service; enabled; vendor preset: disabled)
   Active: active (running) since Mon 2022-10-31 03:28:51 CST; 2 days ago
     Docs: https://docs.docker.com
 Main PID: 11884 (dockerd)
    Tasks: 120
   Memory: 2.7G
   CGroup: /system.slice/docker.service
           ├─  2014 /usr/bin/docker-proxy -proto tcp -host-ip 0.0.0.0 -host-port 8580 -container-ip 172.29.0.2 -container-port 8080
           ├─  2019 /usr/bin/docker-proxy -proto tcp -host-ip :: -host-port 8580 -container-ip 172.29.0.2 -container-port 8080
           ├─  2674 /usr/bin/docker-proxy -proto tcp -host-ip 0.0.0.0 -host-port 8015 -container-ip 172.28.0.2 -container-port 8080
           ├─  2681 /usr/bin/docker-proxy -proto tcp -host-ip :: -host-port 8015 -container-ip 172.28.0.2 -container-port 8080
           ├─  6972 /usr/bin/docker-proxy -proto tcp -host-ip 0.0.0.0 -host-port 8380 -container-ip 172.30.0.2 -container-port 8080
           ├─  6977 /usr/bin/docker-proxy -proto tcp -host-ip :: -host-port 8380 -container-ip 172.30.0.2 -container-port 8080
           ├─ 11884 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
           ├─ 34936 /usr/bin/docker-proxy -proto tcp -host-ip 0.0.0.0 -host-port 8080 -container-ip 172.27.0.3 -container-port 80
           ├─ 34950 /usr/bin/docker-proxy -proto tcp -host-ip :: -host-port 8080 -container-ip 172.27.0.3 -container-port 80
           ├─ 69485 /usr/bin/docker-proxy -proto tcp -host-ip 0.0.0.0 -host-port 8012 -container-ip 172.17.0.4 -container-port 8012
           ├─ 69490 /usr/bin/docker-proxy -proto tcp -host-ip :: -host-port 8012 -container-ip 172.17.0.4 -container-port 8012
           ├─108373 /usr/bin/docker-proxy -proto tcp -host-ip 0.0.0.0 -host-port 7090 -container-ip 172.17.0.5 -container-port 8080
           ├─108378 /usr/bin/docker-proxy -proto tcp -host-ip :: -host-port 7090 -container-ip 172.17.0.5 -container-port 8080
           ├─114721 /usr/bin/docker-proxy -proto tcp -host-ip 0.0.0.0 -host-port 9000 -container-ip 172.17.0.2 -container-port 9000
           ├─114726 /usr/bin/docker-proxy -proto tcp -host-ip :: -host-port 9000 -container-ip 172.17.0.2 -container-port 9000
           ├─125344 /usr/bin/docker-proxy -proto tcp -host-ip 0.0.0.0 -host-port 5000 -container-ip 172.17.0.3 -container-port 5000
           └─125350 /usr/bin/docker-proxy -proto tcp -host-ip :: -host-port 5000 -container-ip 172.17.0.3 -container-port 5000

Nov 02 15:16:34 node dockerd[11884]: time="2022-11-02T15:16:34.836861791+08:00" level=info msg="Download failed, retrying (4/5): Get \"https://prod...
Nov 02 15:22:05 node dockerd[11884]: time="2022-11-02T15:22:05.407264707+08:00" level=error msg="Not continuing with pull after error: con...canceled"
Nov 02 15:22:05 node dockerd[11884]: time="2022-11-02T15:22:05.418587813+08:00" level=info msg="Layer sha256:4fc242d58285699eca05db3cc7c71...eaned up"
Nov 02 15:41:11 node dockerd[11884]: time="2022-11-02T15:41:11.521523907+08:00" level=info msg="Attempting next endpoint for pull after er...ogin yet"
Nov 02 15:41:11 node dockerd[11884]: time="2022-11-02T15:41:11.522439588+08:00" level=error msg="Handler for POST /v1.41/images/create ret...ogin yet"
Nov 02 19:31:41 node dockerd[11884]: time="2022-11-02T19:31:41.114772038+08:00" level=info msg="ignoring event" container=b5ee084a06da9d7a...skDelete"
Nov 02 19:37:20 node dockerd[11884]: time="2022-11-02T19:37:20.995774757+08:00" level=info msg="ignoring event" container=76f027d603614874...skDelete"
Nov 02 19:38:29 node dockerd[11884]: time="2022-11-02T19:38:29.513728257+08:00" level=info msg="ignoring event" container=464a24809eb3af8c...skDelete"
Nov 02 19:45:05 node dockerd[11884]: time="2022-11-02T19:45:05.808404003+08:00" level=info msg="ignoring event" container=66440ac8e1559536...skDelete"
Nov 02 19:50:27 node dockerd[11884]: time="2022-11-02T19:50:27.152222073+08:00" level=info msg="ignoring event" container=d9bcdb2036c3405d...skDelete"
Hint: Some lines were ellipsized, use -l to show in full.

三、搜索nginx镜像

[root@node ~]# docker search nginx
NAME                                              DESCRIPTION                                     STARS     OFFICIAL   AUTOMATED
nginx                                             Official build of Nginx.                        17614     [OK]       
linuxserver/nginx                                 An Nginx container, brought to you by LinuxS…   179                  
bitnami/nginx                                     Bitnami nginx Docker Image                      141                  [OK]
ubuntu/nginx                                      Nginx, a high-performance reverse proxy & we…   64                   
bitnami/nginx-ingress-controller                  Bitnami Docker Image for NGINX Ingress Contr…   22                   [OK]
rancher/nginx-ingress-controller                                                                  11                   
webdevops/nginx                                   Nginx container                                 10                   [OK]
ibmcom/nginx-ingress-controller                   Docker Image for IBM Cloud Private-CE (Commu…   4                    
bitnami/nginx-ldap-auth-daemon                                                                    3                    
bitnami/nginx-exporter                                                                            3                    
vmware/nginx                                                                                      2                    
rancher/nginx-ingress-controller-defaultbackend                                                   2                    
rapidfort/nginx                                   RapidFort optimized, hardened image for NGINX   2                    
kasmweb/nginx                                     An Nginx image based off nginx:alpine and in…   2                    
rancher/nginx                                                                                     2                    
bitnami/nginx-intel                                                                               1                    
wallarm/nginx-ingress-controller                  Kubernetes Ingress Controller with Wallarm e…   1                    
vmware/nginx-photon                                                                               1                    
rancher/nginx-conf                                                                                0                    
rapidfort/nginx-ib                                RapidFort optimized, hardened image for NGIN…   0                    
ibmcom/nginx-ingress-controller-ppc64le           Docker Image for IBM Cloud Private-CE (Commu…   0                    
rancher/nginx-ssl                                                                                 0                    
continuumio/nginx-ingress-ws                                                                      0                    
rancher/nginx-ingress-controller-amd64                                                            0                    
ibmcom/nginx-ppc64le                              Docker image for nginx-ppc64le                  0     

四、创建nginx容器

1.创建数据目录

[root@node ~]# mkdir /data/nginx
[root@node ~]# cd /data/nginx/
[root@node nginx]# ls
[root@node nginx]# 

2.运行nginx容器

[root@node nginx]# docker run -d --name my_web01 --restart always -p 8744:80 -v /data/nginx/:/usr/share/nginx/html/ nginx
Unable to find image 'nginx:latest' locally
latest: Pulling from library/nginx
a2abf6c4d29d: Already exists 
a9edb18cadd1: Pull complete 
589b7251471a: Pull complete 
186b1aaa4aa6: Pull complete 
b4df32aa5a72: Pull complete 
a0bcbecc962e: Pull complete 
Digest: sha256:0d17b565c37bcbd895e9d92315a05c1c3c9a29f762b011a10c54a66cd53c9b31
Status: Downloaded newer image for nginx:latest
349f6f002567d13ec9a4a871b730d85173c7c9a8038067ae4d9369d091e96ba4

3.查看nginx容器状态

[root@node nginx]# docker ps
CONTAINER ID   IMAGE                                                   COMMAND                  CREATED         STATUS                  PORTS                                             NAMES
349f6f002567   nginx                                                   "/docker-entrypoint.…"   2 minutes ago   Up 2 minutes            0.0.0.0:8744->80/tcp, :::8744->80/tcp             my_web01

4.查看容器日志

[root@node nginx]# docker logs my_web01
/docker-entrypoint.sh: /docker-entrypoint.d/ is not empty, will attempt to perform configuration
/docker-entrypoint.sh: Looking for shell scripts in /docker-entrypoint.d/
/docker-entrypoint.sh: Launching /docker-entrypoint.d/10-listen-on-ipv6-by-default.sh
10-listen-on-ipv6-by-default.sh: info: Getting the checksum of /etc/nginx/conf.d/default.conf
10-listen-on-ipv6-by-default.sh: info: Enabled listen on IPv6 in /etc/nginx/conf.d/default.conf
/docker-entrypoint.sh: Launching /docker-entrypoint.d/20-envsubst-on-templates.sh
/docker-entrypoint.sh: Launching /docker-entrypoint.d/30-tune-worker-processes.sh
/docker-entrypoint.sh: Configuration complete; ready for start up
2022/11/02 16:33:36 [notice] 1#1: using the "epoll" event method
2022/11/02 16:33:36 [notice] 1#1: nginx/1.21.5
2022/11/02 16:33:36 [notice] 1#1: built by gcc 10.2.1 20210110 (Debian 10.2.1-6) 
2022/11/02 16:33:36 [notice] 1#1: OS: Linux 3.10.0-957.el7.x86_64
2022/11/02 16:33:36 [notice] 1#1: getrlimit(RLIMIT_NOFILE): 65536:65536
2022/11/02 16:33:36 [notice] 1#1: start worker processes
2022/11/02 16:33:36 [notice] 1#1: start worker process 31
2022/11/02 16:33:36 [notice] 1#1: start worker process 32

五、访问nginx

1.编辑index.html

[root@node nginx]# echo "nginx aa-bb" > index.html
[root@node nginx]# pwd
/data/nginx

2.访问nginx

在这里插入图片描述

标签:原生,container,ip,nginx,host,docker,port
From: https://blog.51cto.com/u_14664141/6469021

相关文章

  • 解密华为云原生媒体网络如何保障实时音视频服务质量
    随着5G和AI的发展,内容表达视频化成为了当今的主流,很多行业对视频分发有非常旺盛的需求。我们非常荣幸地请到了华为云的资深视频架构师黄挺,为大家介绍基于互联网的实时音视频服务所面临的挑战,分享华为云原生媒体网络全方位保障实时音视频服务体验的实践。文/黄挺整理/LiveVideoS......
  • Ubuntu上安装并使用Docker
    第1步-安装Docker官方Ubuntu存储库中提供的Docker安装包,但是可能不是最新的版本。为了确保我们获得最新版本,我们将从官方Docker存储库安装Docker。为此,我们将添加一个新的资源包,从Docker添加GPG密钥以确保下载有效,然后安装该包。1、首先,更新现有的包列表:sudoaptupdate2、接......
  • Elasticsearch8 单机以及集群部署(docker-compose)
    本文以Elasticsearch8.8.0为例,介绍一下单机安装ES,使用docker-compose方式进行便捷管理需要准本docker环境:一键安装脚本 https://www.cnblogs.com/Alay/p/15433473.html需要准备docker-compose环境:一键安装脚本 https://www.cnblogs.com/Alay/p/15433907.html官网阅......
  • Docker 部署jenkins及项目
    本文主要记录如何通过docker安装jenkins,并且通过jenkins部署项目,最终效果是只要在jenkins对某个项目点击构建,jenkins就会去gitLab上拉取最新项目的最新代码,然后根据你自己项目的pom.xml文件,把项目打包成jar,并且自动把这个最新的jar运行起来,达到一键式构建的目标。1、操作1)服务......
  • nginx日志切割
    日志切割(shell脚本)nginx日志默认是不切割的,网站运行久了自然生成大量日志,导致单文件的处理,太麻烦,因此工作里一般定期切割,一般按天切割。-rw-r--r--1rootroot2.1GMay813:57front_access.log 先纯手动的去切割日志,备份日志1.给nginx进程发送信号,让nginx重新......
  • window下安装docker并运行angular项目
    window下安装docker并运行angular项目1、使用场景本地有一个node项目,node版本是v16.13.2,在本地安装的angular是15.2.4但是测试服上面的node版本是14.19.3,angular是1.0.0-beta.28.3,会导致angular项目的ngbuild打包不了。但是不能升级版本,因为这个测试服务器上面的东西也......
  • 通过 docker-compose 快速部署 StarRocks 保姆级教程
    目录一、概述二、前期准备1)部署docker2)部署docker-compose三、创建网络四、StarRocks编排部署1)下载StarRocks部署包2)配置3)启动脚本bootstrap.sh4)构建镜像Dockerfile5)编排docker-compose.yaml6)开始部署五、简单测试验证六、常用的StarRocks客户端命令1)服务启停2、查看节......
  • ELK分析Nginx日志和可视化展示
    ELK分析Nginx日志和可视化展示JAVA编程Linux学习 2023-06-0508:35 发表于山东收录于合集#nginx5个#nginx日志可视化1个#nginx日志1个一、概述使用ELK收集nginxaccess日志,利用Grafana做出一套可视化图表 二、环境准备环境说明操作系统:centos7.6docker......
  • Docker 安装 MySQL8 数据库
    创建数据卷mkdir-p/usr/mysql/conf/usr/mysql/datachmod-R755/usr/mysql/创建配置文件vim/usr/mysql/conf/my.cnf:[client]#socket=/usr/mysql/mysqld.sockdefault-character-set=utf8mb4[mysqld]#pid-file=/var/run/mysqld/mysqld.pid#sock......
  • Docker 安装与升级
    卸载旧版本sudoyumremovedocker\docker-client\docker-client-latest\docker-common\docker-latest\docker-latest-logrotate\docker-logrotate\docker-engine/var/lib/docker/的内容,包括image、container、volumes,andnetworks,将被保留。Docker引擎包现......