bump to latest stable versions

This commit is contained in:
Baohua Yang
2026-02-03 10:14:25 -08:00
parent b92ccc8309
commit 99e0eb14ce
19 changed files with 43 additions and 42 deletions

View File

@@ -1,8 +1,8 @@
# Docker 从入门到实践
[![](https://img.shields.io/github/stars/yeasy/docker_practice.svg?style=social&label=Stars)](https://github.com/yeasy/docker_practice) [![](https://img.shields.io/github/release/yeasy/docker_practice/all.svg)](https://github.com/yeasy/docker_practice/releases) [![](https://img.shields.io/badge/Based-Docker%20CE%20v29.x-blue.svg)](https://github.com/docker/docker-ce) [![](https://img.shields.io/badge/Docker%20%E6%8A%80%E6%9C%AF%E5%85%A5%E9%97%A8%E4%B8%8E%E5%AE%9E%E6%88%98-jd.com-red.svg)][1]
[![](https://img.shields.io/github/stars/yeasy/docker_practice.svg?style=social&label=Stars)](https://github.com/yeasy/docker_practice) [![](https://img.shields.io/github/release/yeasy/docker_practice/all.svg)](https://github.com/yeasy/docker_practice/releases) [![](https://img.shields.io/badge/Based-Docker%20CE%20v30.x-blue.svg)](https://github.com/docker/docker-ce) [![](https://img.shields.io/badge/Docker%20%E6%8A%80%E6%9C%AF%E5%85%A5%E9%97%A8%E4%B8%8E%E5%AE%9E%E6%88%98-jd.com-red.svg)][1]
**v1.4.5**
**v1.4.6**
[Docker](https://www.docker.com) 是个划时代的开源项目,它彻底释放了计算虚拟化的威力,极大提高了应用的维护效率,降低了云计算应用开发的成本!使用 Docker可以让应用的部署、测试和分发都变得前所未有的高效和轻松

View File

@@ -159,15 +159,12 @@ RUN apt-get update && apt-get install -y \
dpkg-sig \
libcap-dev \
libsqlite3-dev \
mercurial \
reprepro \
ruby1.9.1 \
ruby1.9.1-dev \
s3cmd=1.1.* \
git \
redis-server \
&& rm -rf /var/lib/apt/lists/*
```
其中 `s3cmd` 指令指定了一个版本号 `1.1.*`如果之前的镜像使用的是更旧的版本指定新的版本会导致 `apt-get update` 缓存失效并确保安装的是新版本
其中 `redis-server` 是示例包确保安装的是新版本
另外清理掉 apt 缓存 `var/lib/apt/lists` 可以减小镜像大小因为 `RUN` 指令的开头为 `apt-get update`包缓存总是会在 `apt-get install` 之前刷新

View File

@@ -221,7 +221,7 @@ $ docker stop $(docker ps -q) && docker container prune -f
```dockerfile
# Dockerfile 示例
FROM node:18
FROM node:22
...
# 使用 exec 形式确保信号能传递给 node 进程
CMD ["node", "server.js"]

View File

@@ -77,7 +77,7 @@ local redis_data
$ docker volume inspect my-vol
[
{
"CreatedAt": "2024-01-15T10:00:00Z",
"CreatedAt": "2026-01-15T10:00:00Z",
"Driver": "local",
"Labels": {},
"Mountpoint": "/var/lib/docker/volumes/my-vol/_data",

View File

@@ -73,7 +73,7 @@ FROM debian:bookworm
RUN apt-get update
RUN apt-get install -y gcc libc6-dev make wget
RUN wget -O redis.tar.gz "http://download.redis.io/releases/redis-5.0.3.tar.gz"
RUN wget -O redis.tar.gz "http://download.redis.io/releases/redis-7.2.4.tar.gz"
RUN mkdir -p /usr/src/redis
RUN tar -xzf redis.tar.gz -C /usr/src/redis --strip-components=1
RUN make -C /usr/src/redis
@@ -95,7 +95,7 @@ FROM debian:bookworm
RUN set -x; buildDeps='gcc libc6-dev make wget' \
&& apt-get update \
&& apt-get install -y $buildDeps \
&& wget -O redis.tar.gz "http://download.redis.io/releases/redis-5.0.3.tar.gz" \
&& wget -O redis.tar.gz "http://download.redis.io/releases/redis-7.2.4.tar.gz" \
&& mkdir -p /usr/src/redis \
&& tar -xzf redis.tar.gz -C /usr/src/redis --strip-components=1 \
&& make -C /usr/src/redis \

View File

@@ -90,7 +90,7 @@ sha256:07e33465974800ce65751acc279adc6ed2dc5ed4e0838f8b86f0c87aa1795214
$ docker image ls nginx
REPOSITORY TAG IMAGE ID CREATED SIZE
nginx v2 07e334659748 9 seconds ago 181.5 MB
nginx 1.11 05a60462f8ba 12 days ago 181.5 MB
nginx 1.27 05a60462f8ba 12 days ago 181.5 MB
nginx latest e43d811ce2f4 4 weeks ago 181.5 MB
```
@@ -104,7 +104,7 @@ e43d811ce2f4 4 weeks ago /bin/sh -c #(nop) CMD ["nginx" "-g" "da
<missing> 4 weeks ago /bin/sh -c #(nop) EXPOSE 443/tcp 80/tcp 0 B
<missing> 4 weeks ago /bin/sh -c ln -sf /dev/stdout /var/log/nginx/ 22 B
<missing> 4 weeks ago /bin/sh -c apt-key adv --keyserver hkp://pgp. 58.46 MB
<missing> 4 weeks ago /bin/sh -c #(nop) ENV NGINX_VERSION=1.11.5-1 0 B
<missing> 4 weeks ago /bin/sh -c #(nop) ENV NGINX_VERSION=1.27.0-1 0 B
<missing> 4 weeks ago /bin/sh -c #(nop) MAINTAINER NGINX Docker Ma 0 B
<missing> 4 weeks ago /bin/sh -c #(nop) CMD ["/bin/bash"] 0 B
<missing> 4 weeks ago /bin/sh -c #(nop) ADD file:23aa4f893e3288698c 123 MB

View File

@@ -188,5 +188,5 @@ $ docker build --target builder -t username/imagename:tag .
上面例子中我们使用 `COPY --from=0 /go/src/github.com/go/helloworld/app .` 从上一阶段的镜像中复制文件我们也可以复制任意镜像中的文件
```docker
$ COPY --from=nginx:latest /etc/nginx/nginx.conf /nginx.conf
COPY --from=nginx:latest /etc/nginx/nginx.conf /nginx.conf
```

View File

@@ -139,8 +139,8 @@ $ docker image prune -a --filter "until=24h"
# 删除所有 redis 镜像
$ docker rmi $(docker images -q redis)
# 删除 mongo:3.2 之前的所有镜像
$ docker rmi $(docker images -q -f before=mongo:3.2)
# 删除 mongo:8.0 之前的所有镜像
$ docker rmi $(docker images -q -f before=mongo:8.0)
# 删除某个时间之前的镜像
$ docker image prune -a --filter "until=168h" # 7天前

View File

@@ -8,7 +8,7 @@
> **重要提示**CentOS 8 已于 2021 12 31 日停止维护CentOS 7 已于 2024 6 30 日结束支持建议新项目使用 **Rocky Linux** **AlmaLinux** 作为替代
Docker 支持 64 位版本 CentOS 7/8/9StreamRocky Linux 8/9AlmaLinux 8/9并且要求内核版本不低于 3.10CentOS 7 满足最低内核的要求但由于内核版本比较低部分功能 `overlay2` 存储层驱动无法使用并且部分功能可能不太稳定
Docker 支持 64 位版本 CentOS Stream 9Rocky Linux 8/9AlmaLinux 8/9并且要求内核版本不低于 3.10
对于 Rocky LinuxAlmaLinux CentOS Stream推荐使用 `dnf` 包管理器

View File

@@ -8,8 +8,9 @@
Docker 支持以下版本的 [Debian](https://www.debian.org/intro/about) 操作系统:
* Debian Bullseye 11
* Debian Buster 10
* Debian Trixie 13 (stable)
* Debian Bookworm 12 (oldstable)
* Debian Bullseye 11 (LTS)
### 卸载旧版本

View File

@@ -8,8 +8,9 @@
Docker 支持以下版本的 [Fedora](https://getfedora.org/) 操作系统:
* 33
* 34
* 41
* 42
* 43
### 卸载旧版本

View File

@@ -2,7 +2,7 @@
## 系统要求
[Docker Desktop for Mac](https://docs.docker.com/docker-for-mac/) 要求系统最低为 macOS Monterey 12.0 或更高版本,建议升级到最新版本的 macOS(如 Sonoma 或 Ventura
[Docker Desktop for Mac](https://docs.docker.com/docker-for-mac/) 要求系统最低为 macOS Sonora 14.0 或更高版本,建议升级到最新版本的 macOS。
## 安装
@@ -18,7 +18,7 @@ $ brew install --cask docker
如果需要手动下载请点击以下 [链接](https://desktop.docker.com/mac/main/amd64/Docker.dmg) 下载 Docker Desktop for Mac。
> 如果你的电脑搭载的是 M1 芯片`arm64` 架构请点击以下 [链接](https://desktop.docker.com/mac/main/arm64/Docker.dmg) 下载 Docker Desktop for Mac。你可以在 [官方文档](https://docs.docker.com/docker-for-mac/apple-silicon/) 查阅已知的问题。
> 如果你的电脑搭载的是 Apple Silicon 芯片`arm64` 架构请点击以下 [链接](https://desktop.docker.com/mac/main/arm64/Docker.dmg) 下载 Docker Desktop for Mac。你可以在 [官方文档](https://docs.docker.com/docker-for-mac/apple-silicon/) 查阅已知的问题。
如同 macOS 其它软件一样安装也非常简单双击下载的 `.dmg` 文件然后将那只叫 [Moby](https://www.docker.com/blog/call-me-moby-dock/) 的鲸鱼图标拖拽到 `Application` 文件夹即可(其间需要输入用户密码)。

View File

@@ -8,7 +8,9 @@
![Docker-offile-install-top](../.gitbook/assets/image-20200412202617411.png)
## Centos7 离线安装Docker
## CentOS/Rocky/AlmaLinux 离线安装Docker
> 注意以下命令以 CentOS 7 为例对于 CentOS Stream 9Rocky Linux 9 AlmaLinux 9请将 `yum` 替换为 `dnf`并将软件包后缀 `el7` 替换为 `el9`
### YUM本地文件安装推荐

View File

@@ -8,9 +8,9 @@ Docker 不仅支持 `x86_64` 架构的计算机,同时也支持 `ARM` 架构
Docker 支持以下版本的 [Raspberry Pi OS](https://www.raspberrypi.org/software/operating-systems/) 操作系统:
* Raspberry Pi OS Buster
* Raspberry Pi OS Bullseye
* Raspberry Pi OS Trixie
* Raspberry Pi OS Bookworm
* Raspberry Pi OS Bullseye
** `Raspberry Pi OS` 由树莓派的开发与维护机构 [树莓派基金会](https://www.raspberrypi.org/) 官方支持,并推荐用作树莓派的首选系统,其基于 `Debian`。

View File

@@ -8,11 +8,11 @@
Docker 支持诸多版本的 [Ubuntu](https://ubuntu.com/server) 操作系统。但是较旧的版本上将不会有 Docker 新版本的持续更新,以截至 2026 年初的几个 Ubuntu LTSLong Term Support长期支持版本为例
* Ubuntu Noble 24.04 (LTS)Docker v29.1.x
* Ubuntu Jammy 22.04 (LTS), Docker v29.1.x
* Ubuntu Focal 20.04 (LTS), Docker v29.1.x
> **注意**Ubuntu 18.04 LTS 已于 2023 年结束标准支持不再推荐用于新部署
* Ubuntu Noble 24.04 (LTS)Docker v30.x
* Ubuntu Jammy 22.04 (LTS), Docker v30.x
> **注意**Ubuntu 20.04 LTS 已于 2025 年结束标准支持不再推荐用于新部署
Ubuntu LTS 版本上目前 Docker 支持 amd64arm64armhfppc64els390x 5 个平台而非 LTS 版本支持的平台通常较少同时LTS 版本会获得 5 年的升级维护支持这样的系统会获得更长期的安全保障因此在生产环境中推荐使用 LTS 版本

View File

@@ -2,7 +2,7 @@
## 系统要求
[Docker Desktop for Windows](https://docs.docker.com/docker-for-windows/install/) 支持 64 位版本的 Windows 10 Pro且必须开启 Hyper-V若版本为 v1903 及以上则无需开启 Hyper-V或者 64 位版本的 Windows 10 Home v1903 及以上版本
[Docker Desktop for Windows](https://docs.docker.com/docker-for-windows/install/) 支持 64 位版本的 Windows 11 或 Windows 10需开启 Hyper-V推荐使用 Windows 11
## 安装

View File

@@ -17,8 +17,8 @@ Docker 做的事情类似:无论你的应用是用 Python、Java、Node.js 还
```
开发环境 生产环境
┌─────────────────┐ ┌─────────────────┐
│ Python 3.9 │ ≠ │ Python 3.7
│ Ubuntu 22.04 │ │ CentOS 7
│ Python 3.14 │ ≠ │ Python 3.11
│ Ubuntu 24.04 │ │ Ubuntu 22.04
│ 特定版本的库 │ │ 不同版本的库 │
└─────────────────┘ └─────────────────┘
↓ ↓
@@ -110,7 +110,7 @@ Docker 的发展历程:
- **2013 3 **开源发布
- **2013 年底**dotCloud 公司改名为 Docker, Inc.
- **2015 **成立 [开放容器联盟OCI](https://opencontainers.org/),推动容器标准化
- **至今**[GitHub 项目](https://github.com/moby/moby) 超过 6.8 万星标
- **至今**[GitHub 项目](https://github.com/moby/moby) 超过 7 万星标
Docker 的成功推动了整个容器生态的发展催生了 KubernetesPodman 等众多相关项目笔者认为Docker 最大的贡献不仅是技术本身更是它**让容器技术从系统管理员的工具变成了每个开发者都能使用的标准工具**

View File

@@ -97,7 +97,7 @@ REPOSITORY TAG IMAGE ID CREAT
这是因为 Docker 默认不允许非 `HTTPS` 方式推送镜像我们可以通过 Docker 的配置选项来取消这个限制或者查看下一节配置能够通过 `HTTPS` 访问的私有仓库
### Ubuntu 16.04+, Debian 8+, centos 7
### Linux (systemd)
对于使用 `systemd` 的系统请在 `/etc/docker/daemon.json` 中写入如下内容如果文件不存在请新建该文件

View File

@@ -129,7 +129,7 @@ $ docker pull myregistry/myimage:latest
> 笔者强调这是最重要的安全实践之一
```dockerfile
FROM node:20-alpine
FROM node:22-alpine
# 创建非 root 用户
RUN addgroup -g 1001 appgroup && \
@@ -201,11 +201,11 @@ $ docker run --network=isolated_net myapp
```dockerfile
# ✅ 好:使用精简镜像
FROM node:20-alpine # ~50MB
FROM node:22-alpine # ~50MB
FROM gcr.io/distroless/nodejs # ~20MB
# ❌ 差:使用完整镜像
FROM node:20 # ~1GB
FROM node:22 # ~1GB
FROM ubuntu:24.04 # ~78MB
```
@@ -213,13 +213,13 @@ FROM ubuntu:24.04 # ~78MB
```dockerfile
# 构建阶段
FROM node:20 AS builder
FROM node:22 AS builder
WORKDIR /app
COPY . .
RUN npm install && npm run build
# 生产阶段(不包含开发依赖和源码)
FROM node:20-alpine
FROM node:22-alpine
COPY --from=builder /app/dist /app
USER node
CMD ["node", "/app/server.js"]
@@ -240,7 +240,7 @@ COPY .env /app/
```dockerfile
# ✅ 固定版本
FROM node:20.10.0-alpine3.19
FROM node:22.12.0-alpine3.21
RUN apk add --no-cache curl=8.5.0-r0
# ❌ 使用 latest