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;
    #    }
    #}

}
相关推荐
Dontla1 小时前
Docker run --add-host参数解析(在容器启动时向/etc/hosts文件中添加自定义的主机名与IP映射)(适用于临时调试或测试)
tcp/ip·docker·容器
西西小飞龙1 小时前
Docker和K8S中pod、services、container的介绍和关系
docker·容器·kubernetes
元气满满的热码式1 小时前
Docker数据卷操作实战
linux·运维·docker·云原生·容器
kngines1 小时前
【实战 ES】实战 Elasticsearch:快速上手与深度实践-1.3.1单节点安装(Docker与手动部署)
大数据·elasticsearch·docker
陆沙1 小时前
deepseek-r1-centos-本地服务器配置方法
linux·服务器·centos
sz66cm2 小时前
Linux基础 -- ARM 32 位架构动态注入代码技术文档
linux·arm开发·架构
网硕互联的小客服11 小时前
服务器硬件老化导致性能下降的排查与优化
linux·运维·服务器·安全·centos
ForTodayzzZ12 小时前
centos和ubuntu安装mysql教程
linux·mysql·ubuntu·centos
飞火流星0202712 小时前
docker安装etcd:docker离线安装etcd、docker在线安装etcd、etcd镜像下载、etcd配置详解、etcd常用命令、安装常见问题总结
docker·容器·etcd
web1478621072313 小时前
Linux(CentOS)安装 Nginx
linux·nginx·centos