centos arm docker 安装nginx

1. 查找 ARM 版的 Nginx 镜像

因为是 ARM 架构,确保拉取到适合的 Nginx 镜像。在 Docker Hub 上,官方的 Nginx 镜像通常已经支持多架构。

你可以使用以下命令来拉取 Nginx:

bash 复制代码
docker pull nginx

Docker 会自动选择与你架构兼容的版本。

如果因网络原因无法正常下载,则通过以下链接进行免费下载https://download.csdn.net/download/qq_34322136/89734227

2. 运行 Nginx 容器

拉取镜像后,可以使用以下命令运行 Nginx 容器:

bash 复制代码
docker run --name mynginx -p 80:80 -d nginx

这个命令会在前台运行 Nginx 并将主机的 80 端口映射到容器的 80 端口。

3. 验证 Nginx 是否启动

运行以下命令查看正在运行的容器:

bash 复制代码
docker ps

你应该能够看到 nginx 容器在运行。现在你可以通过访问 CentOS ARM 主机的 IP 地址来验证 Nginx 是否工作正常。

例如,访问 http://<your_server_ip>,应该可以看到 Nginx 欢迎页面。

4. 自定义 Nginx 配置(可选)

如果你想自定义 Nginx 配置,可以通过挂载配置文件目录的方式实现。例如,将自定义的 Nginx 配置文件挂载到容器中:

bash 复制代码
docker run --name mynginx -p 80:80 -v /home/kubernetes/nginx/conf/nginx.conf:/etc/nginx/nginx.conf:ro -d nginx

这样,Nginx 将使用你提供的配置文件启动。

完成这些步骤后,Nginx 应该已经在 CentOS ARM 上成功运行。

nginx.conf配置实例:

bash 复制代码
#user  nobody;
worker_processes  1;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;


events {
    worker_connections  1024;
}


http {
    include       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  logs/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    #gzip  on;

    server {
        listen       80;
        server_name  localhost;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            root   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   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;
        #}
    }


    # another virtual host using mix of IP-, name-, and port-based configuration
    #
    #server {
    #    listen       8000;
    #    listen       somename:8080;
    #    server_name  somename  alias  another.alias;

    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}


    # HTTPS server
    #
    #server {
    #    listen       443 ssl;
    #    server_name  localhost;

    #    ssl_certificate      cert.pem;
    #    ssl_certificate_key  cert.key;

    #    ssl_session_cache    shared:SSL:1m;
    #    ssl_session_timeout  5m;

    #    ssl_ciphers  HIGH:!aNULL:!MD5;
    #    ssl_prefer_server_ciphers  on;

    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}

}
相关推荐
乔旭伟1 小时前
CentOS 停更迁移实战:vault 源配置、目标选型与迁移工程清单
linux·运维·centos
EterNity_TiMe_2 小时前
Docker服务越装越多记不住端口?我用Fenrus把NAS里的常用入口整理成一个导航页
运维·人工智能·docker·ai·容器·cpolar
吴声子夜歌2 小时前
Docker入门与实战——libnetwork插件化网络功能
网络·docker·容器
szxinmai主板定制专家3 小时前
ZYNQ PL+PS 架构拆解|工业自动化与电力物联网高速数据采集、预处理与协议上云
arm开发·人工智能·物联网·fpga开发·数据采集卡·rk3576
江湖有缘3 小时前
Docker实战 | 使用Docker部署HarborGuard容器安全扫描平台
安全·docker·容器
江湖有缘3 小时前
Docker实战 | 使用Docker部署Reubah文件转换器和图像处理器
docker·容器·eureka
szxinmai主板定制专家4 小时前
告别 ARM 实时性短板:基于 ZYNQ 的电力故障录波 + 工业振动数据采集系统设计
arm开发·人工智能·fpga开发·zynq·数据采集卡·arm+fpga·rk3588+fpga
骑着蜗牛撵大象3274 小时前
ToolJet + PostgreSQL:后台表格、查询和流程,一次搭成可远程访问的业务系统
数据库·低代码·docker·postgresql·内部工具·tooljet
flytalei5 小时前
从 Docker Compose 到 K3s:逐浪笔记首次完整部署与故障排查实战
笔记·docker·容器
吴声子夜歌6 小时前
Docker入门与实战——高级网络功能
网络·docker