专属域名
文档搜索
轩辕助手
Run助手
邀请有礼
返回顶部
快速返回页面顶部
收起
收起工具栏
轩辕镜像 官方专业版
轩辕镜像 官方专业版轩辕镜像 官方专业版官方专业版
首页个人中心搜索镜像

交易
充值流量我的订单
工具
提交工单镜像收录一键安装
Npm 源Pip 源Homebrew 源
帮助
常见问题
其他
关于我们网站地图

官方QQ群: 1072982923

热门搜索:openclaw🔥nginx🔥redis🔥mysqlopenjdkcursorweb2apimemgraphzabbixetcdubuntucorednsjdk
nginx

library/nginx

Docker 官方镜像

Nginx 官方 Docker 镜像,提供高性能 Web 服务器和反向代理能力,适合部署静态站点、反向代理和负载均衡入口,可通过挂载配置和静态目录快速搭建统一的 Web 与 API 网关层。

2.1万 次收藏下载次数: 0状态:Docker 官方镜像维护者:Docker 官方镜像仓库类型:镜像最近更新:1 天前
使用轩辕镜像,把时间还给真正重要的事。点击查看
版本下载
使用轩辕镜像,把时间还给真正重要的事。点击查看

Quick reference

  • Maintained by:
    https://github.com/nginxinc/docker-nginx

  • Where to get help:
    the Docker Community Slack, Server Fault, Unix & Linux, or Stack Overflow

Supported tags and respective Dockerfile links

  • https://github.com/nginx/docker-nginx/blob/71081b25390771f6b1275ddf7c73c965f304493f/mainline/debian/Dockerfile

  • https://github.com/nginx/docker-nginx/blob/71081b25390771f6b1275ddf7c73c965f304493f/mainline/debian-perl/Dockerfile

  • https://github.com/nginx/docker-nginx/blob/71081b25390771f6b1275ddf7c73c965f304493f/mainline/debian-otel/Dockerfile

  • https://github.com/nginx/docker-nginx/blob/71081b25390771f6b1275ddf7c73c965f304493f/mainline/alpine/Dockerfile

  • https://github.com/nginx/docker-nginx/blob/71081b25390771f6b1275ddf7c73c965f304493f/mainline/alpine-perl/Dockerfile

  • https://github.com/nginx/docker-nginx/blob/71081b25390771f6b1275ddf7c73c965f304493f/mainline/alpine-slim/Dockerfile

  • https://github.com/nginx/docker-nginx/blob/71081b25390771f6b1275ddf7c73c965f304493f/mainline/alpine-otel/Dockerfile

  • https://github.com/nginx/docker-nginx/blob/30c9ebf5aba124ca7bd79f97dd7c825c113ed864/stable/debian/Dockerfile

  • https://github.com/nginx/docker-nginx/blob/30c9ebf5aba124ca7bd79f97dd7c825c113ed864/stable/debian-perl/Dockerfile

  • https://github.com/nginx/docker-nginx/blob/30c9ebf5aba124ca7bd79f97dd7c825c113ed864/stable/debian-otel/Dockerfile

  • https://github.com/nginx/docker-nginx/blob/30c9ebf5aba124ca7bd79f97dd7c825c113ed864/stable/alpine/Dockerfile

  • https://github.com/nginx/docker-nginx/blob/30c9ebf5aba124ca7bd79f97dd7c825c113ed864/stable/alpine-perl/Dockerfile

  • https://github.com/nginx/docker-nginx/blob/30c9ebf5aba124ca7bd79f97dd7c825c113ed864/stable/alpine-slim/Dockerfile

  • https://github.com/nginx/docker-nginx/blob/30c9ebf5aba124ca7bd79f97dd7c825c113ed864/stable/alpine-otel/Dockerfile

Quick reference (cont.)

  • Where to file issues:
    https://github.com/nginxinc/docker-nginx/issues?q=

  • Supported architectures: (https://github.com/docker-library/official-images#architectures-other-than-amd64)
    https://hub.docker.com/r/amd64/nginx/, https://hub.docker.com/r/arm32v5/nginx/, https://hub.docker.com/r/arm32v6/nginx/, https://hub.docker.com/r/arm32v7/nginx/, https://hub.docker.com/r/arm64v8/nginx/, https://hub.docker.com/r/i386/nginx/, https://hub.docker.com/r/ppc64le/nginx/, https://hub.docker.com/r/riscv64/nginx/, https://hub.docker.com/r/s390x/nginx/

  • Published image artifact details:
    https://github.com/docker-library/repo-info/blob/master/repos/nginx (https://github.com/docker-library/repo-info/commits/master/repos/nginx)
    (image metadata, transfer size, etc)

  • Image updates:
    https://github.com/docker-library/official-images/issues?q=label%3Alibrary%2Fnginx
    https://github.com/docker-library/official-images/blob/master/library/nginx (https://github.com/docker-library/official-images/commits/master/library/nginx)

  • Source of this description:
    https://github.com/docker-library/docs/tree/master/nginx (https://github.com/docker-library/docs/commits/master/nginx)

What is nginx?

Nginx (pronounced "engine-x") is an open source reverse proxy server for HTTP, HTTPS, SMTP, POP3, and IMAP protocols, as well as a load ***, HTTP cache, and a web server (origin server). The nginx project started with a strong focus on high concurrency, high performance and low memory usage. It is licensed under the 2-clause BSD-like license and it runs on Linux, BSD variants, Mac OS X, Solaris, AIX, HP-UX, as well as on other *nix flavors. It also has a proof of concept port for Microsoft Windows.

***.org/wiki/Nginx

!https://raw.githubusercontent.com/docker-library/docs/01c***b2fe592c1f93a13b4e289ada0e3a1/nginx/logo.png

How to use this image

Hosting some simple static content

console
$ docker run --name some-nginx -v /some/content:/usr/share/nginx/html:ro -d nginx

Alternatively, a simple Dockerfile can be used to generate a new image that includes the necessary content (which is a much cleaner solution than the bind mount above):

dockerfile
FROM nginx
COPY static-html-directory /usr/share/nginx/html

Place this file in the same directory as your directory of content ("static-html-directory"), then run these commands to build and start your container:

console
$ docker build -t some-content-nginx .
$ docker run --name some-nginx -d some-content-nginx

Exposing external port

console
$ docker run --name some-nginx -d -p 8080:80 some-content-nginx

Then you can hit http://localhost:8080 or http://host-ip:8080 in your browser.

Customize configuration

You can mount your configuration file, or build a new image with it.

If you wish to adapt the default configuration, use something like the following to get it from a running nginx container:

console
$ docker run --rm --entrypoint=cat nginx /etc/nginx/nginx.conf > /host/path/nginx.conf

And then edit /host/path/nginx.conf in your host file system.

For information on the syntax of the nginx configuration files, see the official documentation (specifically the Beginner's Guide).

Mount your configuration file

console
$ docker run --name my-custom-nginx-container -v /host/path/nginx.conf:/etc/nginx/nginx.conf:ro -d nginx

Build a new image with your configuration file

dockerfile
FROM nginx
COPY nginx.conf /etc/nginx/nginx.conf

If you add a custom CMD in the Dockerfile, be sure to include -g daemon off; in the CMD in order for nginx to stay in the foreground, so that Docker can track the process properly (otherwise your container will stop immediately after starting)!

Then build the image with docker build -t custom-nginx . and run it as follows:

console
$ docker run --name my-custom-nginx-container -d custom-nginx

Using environment variables in nginx configuration (new in 1.19)

Out-of-the-box, nginx doesn't support environment variables inside most configuration blocks. But this image has a function, which will extract environment variables before nginx starts.

Here is an example using compose.yaml:

yaml
web:
  image: nginx
  volumes:
   - ./templates:/etc/nginx/templates
  ports:
   - "8080:80"
  environment:
   - NGINX_HOST=foobar.com
   - NGINX_PORT=80

By default, this function reads template files in /etc/nginx/templates/*.template and outputs the result of executing envsubst to /etc/nginx/conf.d.

So if you place templates/default.conf.template file, which contains variable references like this:

listen       ${NGINX_PORT};

outputs to /etc/nginx/conf.d/default.conf like this:

listen       80;

This behavior can be changed via the following environment variables:

  • NGINX_ENVSUBST_TEMPLATE_DIR
    • A directory which contains template files (default: /etc/nginx/templates)
    • When this directory doesn't exist, this function will do nothing about template processing.
  • NGINX_ENVSUBST_TEMPLATE_SUFFIX
    • A suffix of template files (default: .template)
    • This function only processes the files whose name ends with this suffix.
  • NGINX_ENVSUBST_OUTPUT_DIR
    • A directory where the result of executing envsubst is output (default: /etc/nginx/conf.d)
    • The output filename is the template filename with the suffix removed.
      • ex.) /etc/nginx/templates/default.conf.template will be output with the filename /etc/nginx/conf.d/default.conf.
    • This directory must be writable by the user running a container.

Running nginx in read-only mode

To run nginx in read-only mode, you will need to mount a Docker volume to every location where nginx writes information. The default nginx configuration requires write access to /var/cache/nginx and /var/run. This can be easily accomplished by running nginx as follows:

console
$ docker run -d -p 80:80 --read-only -v $(pwd)/nginx-cache:/var/cache/nginx -v $(pwd)/nginx-pid:/var/run nginx

If you have a more advanced configuration that requires nginx to write to other locations, simply add more volume mounts to those locations.

Running nginx in debug mode

Images since version 1.9.8 come with nginx-debug binary that produces verbose output when using higher log levels. It can be used with simple CMD substitution:

console
$ docker run --name my-nginx -v /host/path/nginx.conf:/etc/nginx/nginx.conf:ro -d nginx nginx-debug -g 'daemon off;'

Similar configuration in compose.yaml may look like this:

yaml
web:
  image: nginx
  volumes:
    - ./nginx.conf:/etc/nginx/nginx.conf:ro
  command: [nginx-debug, '-g', 'daemon off;']

Entrypoint quiet logs

Since version 1.19.0, a verbose entrypoint was added. It provides information on what's happening during container startup. You can silence this output by setting environment variable NGINX_ENTRYPOINT_QUIET_LOGS:

console
$ docker run -d -e NGINX_ENTRYPOINT_QUIET_LOGS=1 nginx

User and group id

Since 1.17.0, both alpine- and debian-based images variants use the same user and group ids to drop the privileges for worker processes:

console
$ id
uid=101(nginx) gid=101(nginx) groups=101(nginx)

Running nginx as a non-root user

It is possible to run the image as a less privileged arbitrary UID/GID. This, however, requires modification of nginx configuration to use directories writeable by that specific UID/GID pair:

console
$ docker run -d -v $PWD/nginx.conf:/etc/nginx/nginx.conf nginx

where nginx.conf in the current directory should have the following directives re-defined:

nginx
pid        /tmp/nginx.pid;

And in the http context:

nginx
http {
    client_body_temp_path /tmp/client_temp;
    proxy_temp_path       /tmp/proxy_temp_path;
    fastcgi_temp_path     /tmp/fastcgi_temp;
    uwsgi_temp_path       /tmp/uwsgi_temp;
    scgi_temp_path        /tmp/scgi_temp;
...
}

Alternatively, check out the official https://hub.docker.com/r/nginxinc/nginx-unprivileged.

Image Variants

The nginx images come in many flavors, each designed for a specific use case.

nginx:<version>

This is the defacto image. If you are unsure about what your needs are, you probably want to use this one. It is designed to be used both as a throw away container (mount your source code and start the container to start your app), as well as the base to build other images off of.

Some of these tags may have names like trixie in them. These are the suite code names for releases of Debian and indicate which release the image is based on. If your image needs to install any additional packages beyond what comes with the image, you'll likely want to specify one of these explicitly to minimize breakage when there are new releases of Debian.

nginx:<version>-perl / nginx:<version>-alpine-perl

Starting with nginx:1.13.0 / mainline and nginx:1.12.0 / stable, the perl module has been removed from the default images. A separate -perl tag variant is available if you wish to use the perl module.

nginx:<version>-alpine

This image is based on the popular Alpine Linux project, available in https://hub.docker.com/_/alpine. Alpine Linux is much smaller than most distribution base images (~5MB), and thus leads to much slimmer images in general.

This variant is useful when final image size being as small as possible is your primary concern. The main caveat to note is that it does use musl libc instead of glibc and friends, so software will often run into issues depending on the depth of their libc requirements/assumptions. See this Hacker News comment thread for more discussion of the issues that might arise and some pro/con comparisons of using Alpine-based images.

To minimize image size, it's uncommon for additional related tools (such as git or bash) to be included in Alpine-based images. Using this image as a base, add the things you need in your own Dockerfile (see the https://hub.docker.com/_/alpine/ for examples of how to install packages if you are unfamiliar).

nginx:<version>-slim

This image does not contain the common packages contained in the default tag and only contains the minimal packages needed to run nginx. Unless you are working in an environment where only the nginx image will be deployed and you have space constraints, we highly recommend using the default image of this repository.

License

View license information for the software contained in this image.

As with all Docker images, these likely also contain other software which may be under other licenses (such as Bash, etc from the base distribution, along with any direct or indirect dependencies of the primary software being contained).

Some additional license information which was able to be auto-detected might be found in https://github.com/docker-library/repo-info/tree/master/repos/nginx.

As for any pre-built image usage, it is the image user's responsibility to ensure that any use of this image complies with any relevant licenses for all software contained within.

Deployment & Usage Documentation

(2 articles)

从零开始学构建Docker镜像:4种实用方法+生产级实践规范

本文偏向生产与工程实践,新手可跳过部分进阶章节(如CI/CD自动化、多阶段构建优化),优先掌握基础构建方法与核心规范。Docker镜像作为容器的“基石”,掌握镜像构建是玩转Docker的核心技能。本文先完成Docker环境搭建,再拆解4种构建方法与实战案例,同时补充**安全声明、生产规范与禁用场景**,适配个人开发、团队协作及准生产环境需求,帮助建立正确的技术认知与实践边界。

Read More

手把手教你使用 Docker 部署 Nginx 教程

本文详细介绍了基于轩辕镜像的 Nginx 镜像拉取方法(含登录验证、免登录(推荐)、官方直连等方式),以及三种适合不同场景的 Docker 部署方案(快速部署用于测试、目录挂载用于实际项目、docker-compose 用于企业级场景),同时提供了服务验证步骤和常见问题解决方案(如端口访问、HTTPS 配置、日志切割、时区修正),内容循序渐进、操作指令完整,专为初学者设计,可直接对照执行完成 Nginx 部署。

Read More

查看更多 nginx 相关镜像 →

nginx/nginx-ingress logo

nginx/nginx-ingress

NGINX 官方镜像
NGINX和NGINX Plus入口控制器是专为Kubernetes设计的流量管理工具,主要用于管理外部HTTP/HTTPS流量进入Kubernetes集群,支持请求路由、负载均衡、SSL终止、流量控制等功能,适用于容器化应用和微服务架构,其中NGINX Plus还提供商业支持、高级监控和增强的负载均衡能力,帮助提升集群流量管理的效率与安全性。
117 次收藏10亿+ 次下载
17 小时前更新
nginx/nginx-prometheus-exporter logo

nginx/nginx-prometheus-exporter

NGINX 官方镜像
NGINX Prometheus Exporter用于收集并导出NGINX与NGINX Plus的监控指标,供Prometheus采集以实现对其运行状态的监控。
51 次收藏5000万+ 次下载
1 个月前更新
nginx/unit logo

nginx/unit

NGINX 官方镜像
此仓库已停用,建议用户改用Docker官方提供的镜像,具体官方镜像可通过链接[***]
66 次收藏1000万+ 次下载
3 年前更新
nginx/nginx-ingress-operator logo

nginx/nginx-ingress-operator

NGINX 官方镜像
用于NGINX和NGINX Plus入口控制器的NGINX入口操作器,基于Helm图表构建。
3 次收藏100万+ 次下载
11 天前更新
NGINX Development Center logo

extension/nginx

extension
NGINX Development Center for Docker Desktop
5万+ 次下载
2 年前更新
nginx/nginx-quic-qns logo

nginx/nginx-quic-qns

NGINX 官方镜像
用于 NGINX QUIC 协议互操作性测试的 Docker 镜像,集成 QUIC 支持,简化 QUIC 实现的兼容性验证与功能测试流程。
1 次收藏1万+ 次下载
4 年前更新

轩辕镜像配置手册

探索更多轩辕镜像的使用方法,找到最适合您系统的配置方式

Docker 配置

登录仓库拉取

通过 Docker 登录认证访问私有仓库

专属域名拉取

无需登录使用专属域名

K8s Containerd

Kubernetes 集群配置 Containerd

K3s

K3s 轻量级 Kubernetes 镜像加速

Dev Containers

VS Code Dev Containers 配置

Podman

Podman 容器引擎配置

Singularity/Apptainer

HPC 科学计算容器配置

其他仓库配置

ghcr、Quay、nvcr 等镜像仓库

Harbor 镜像源配置

Harbor Proxy Repository 对接专属域名

Portainer 镜像源配置

Portainer Registries 加速拉取

Nexus 镜像源配置

Nexus3 Docker Proxy 内网缓存

系统配置

Linux

在 Linux 系统配置镜像服务

Windows/Mac

在 Docker Desktop 配置镜像

MacOS OrbStack

MacOS OrbStack 容器配置

Docker Compose

Docker Compose 项目配置

NAS 设备

群晖

Synology 群晖 NAS 配置

飞牛

飞牛 fnOS 系统配置镜像

绿联

绿联 NAS 系统配置镜像

威联通

QNAP 威联通 NAS 配置

极空间

极空间 NAS 系统配置服务

网络设备

爱快路由

爱快 iKuai 路由系统配置

宝塔面板

在宝塔面板一键配置镜像

需要其他帮助?请查看我们的 常见问题Docker 镜像访问常见问题解答 或 提交工单

镜像拉取常见问题

使用与功能问题

配置了专属域名后,docker search 为什么会报错?

docker search 限制

Docker Hub 上有的镜像,为什么在轩辕镜像网站搜不到?

站内搜不到镜像

机器不能直连外网时,怎么用 docker save / load 迁镜像?

离线 save/load

docker pull 拉插件报错(plugin v1+json)怎么办?

插件要用 plugin install

WSL 里 Docker 拉镜像特别慢,怎么排查和优化?

WSL 拉取慢

轩辕镜像安全吗?如何用 digest 校验镜像没被篡改?

安全与 digest

第一次用轩辕镜像拉 Docker 镜像,要怎么登录和配置?

新手拉取配置

错误码与失败问题

docker pull 提示 manifest unknown 怎么办?

manifest unknown

docker pull 提示 no matching manifest 怎么办?

no matching manifest(架构)

镜像已拉取完成,却提示 invalid tar header 或 failed to register layer 怎么办?

invalid tar header(解压)

Docker pull 时 HTTPS / TLS 证书验证失败怎么办?

TLS 证书失败

Docker pull 时 DNS 解析超时或连不上仓库怎么办?

DNS 超时

Docker 拉取出现 410 Gone 怎么办?

410 Gone 排查

出现 402 或「流量用尽」提示怎么办?

402 与流量用尽

Docker 拉取提示 UNAUTHORIZED(401)怎么办?

401 认证失败

遇到 429 Too Many Requests(请求太频繁)怎么办?

429 限流

docker login 提示 Cannot autolaunch D-Bus,还算登录成功吗?

D-Bus 凭证提示

为什么会出现「单层超过 20GB」或 413,无法加速拉取?

413 与超大单层

账号 / 计费 / 权限

轩辕镜像免费版和专业版有什么区别?

免费版与专业版区别

轩辕镜像支持哪些 Docker 镜像仓库?

支持的镜像仓库

镜像拉取失败还会不会扣流量?

失败是否计费

麒麟 V10 / 统信 UOS 提示 KYSEC 权限不够怎么办?

KYSEC 拦截脚本

如何在轩辕镜像申请开具发票?

申请开票

怎么修改轩辕镜像的网站登录和仓库登录密码?

修改登录密码

如何注销轩辕镜像账户?要注意什么?

注销账户

配置与原理类

写了 registry-mirrors,为什么还是走官方或仍然报错?

mirrors 不生效

怎么用 docker tag 去掉镜像名里的轩辕域名前缀?

去掉域名前缀

如何拉取指定 CPU 架构的镜像(如 ARM64、AMD64)?

指定架构拉取

用轩辕镜像拉镜像时快时慢,常见原因有哪些?

拉取速度原因

查看全部问题→

用户好评

来自真实用户的反馈,见证轩辕镜像的优质服务

用户头像

oldzhang

运维工程师

Linux服务器

5

"Docker访问体验非常流畅,大镜像也能快速完成下载。"

轩辕镜像
Docker 官方镜像
...
library/nginx
博客公告Docker 镜像公告与技术博客
热门镜像查看热门 Docker 镜像推荐
一键安装一键安装 Docker 并配置镜像源
镜像拉取问题咨询请 提交工单,官方技术交流群:1072982923。轩辕镜像所有镜像均来源于原始仓库,本站不存储、不修改、不传播任何镜像内容。
镜像拉取问题咨询请提交工单,官方技术交流群:。轩辕镜像所有镜像均来源于原始仓库,本站不存储、不修改、不传播任何镜像内容。
商务合作:点击复制邮箱
©2024-2026 源码跳动
商务合作:点击复制邮箱Copyright © 2024-2026 杭州源码跳动科技有限公司. All rights reserved.