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

}
相关推荐
云途行者6 分钟前
使用 docker 安装 openldap
运维·docker·容器
Andy杨3 小时前
20250718-1-Kubernetes 应用程序生命周期管理-应用部署、升级、弹性_笔记
linux·docker·容器
别致的影分身9 小时前
Docker 镜像原理
运维·docker·容器
阿葱(聪)9 小时前
java 在k8s中的部署流程
java·开发语言·docker·kubernetes
Elastic 中国社区官方博客11 小时前
在 Windows 上使用 Docker 运行 Elastic Open Crawler
大数据·windows·爬虫·elasticsearch·搜索引擎·docker·容器
玄辰星君11 小时前
【MAC】nacos 2.5.1容器docker安装
macos·docker·nacos
土小帽软件测试11 小时前
docker安装、启动jenkins服务,创建接口自动化定时任务(mac系统)
docker·容器·jenkins
世纪摆渡人11 小时前
部署-k8s和docker、jenkins的区别和联系
docker·kubernetes·jenkins
明天…ling11 小时前
docker+小皮面板
运维·docker·容器
witton15 小时前
x86版Ubuntu的容器中运行ARM版Ubuntu
linux·arm开发·ubuntu·docker·容器·arm·qemu