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 小时前
一键启动:使用 start-local 脚本轻松管理 INFINI Console 与 Easysearch 本地环境
数据库·docker
❀͜͡傀儡师1 小时前
docker 安装数据集成平台 Apache SeaTunnel 服务
docker·容器
代码改变世界ctw1 小时前
1.4 ARM安全参考架构(PSA Certified)
arm开发·安全·arm·trustzone·atf·optee·安全启动
超级小忍2 小时前
Spring Boot 与 Docker 的完美结合:容器化你的应用
spring boot·后端·docker
B1nna4 小时前
Docker学习
学习·docker·容器
缘友一世4 小时前
网安系列【15】之Docker未授权访问漏洞
docker·容器
慕木兮人可11 小时前
Docker部署MySQL镜像
spring boot·后端·mysql·docker·ecs服务器
代码改变世界ctw13 小时前
ARM汇编编程(AArch64架构)课程 - 第5章函数调用规范
汇编·arm开发·架构
芯岭技术14 小时前
MS32C001-C单片机,32位ARM M0+内核,宽电压、低功耗、小封装。
c语言·arm开发·单片机
armcsdn15 小时前
基于Docker Compose部署Traccar容器与主机MySQL的完整指南
mysql·docker·容器