Release v1.5.0: Restructure chapters and update for Docker v30.x

This commit is contained in:
Baohua Yang
2026-02-04 22:12:38 -08:00
parent b4b0d4160a
commit fdb879dcf2
304 changed files with 1314 additions and 364 deletions

136
14_cases/os/debian.md Normal file
View File

@@ -0,0 +1,136 @@
# Debian Ubuntu
`Debian` `Ubuntu` 都是目前较为流行的 **Debian ** 的服务器操作系统十分适合研发场景`Docker Hub` 上提供了官方镜像国内各大容器云服务也基本都提供了相应的支持
## Debian 系统简介
![Debian 操作系统](../../_images/debian-logo.png)
`Debian` 是由 `GPL` 和其他自由软件许可协议授权的自由软件组成的操作系统 **Debian 计划Debian Project** 组织维护**Debian 计划** 是一个独立的分散的组织 `3000` 人志愿者组成接受世界多个非盈利组织的资金支持`Software in the Public Interest` 提供支持并持有商标作为保护机构`Debian` 以其坚守 `Unix` 和自由软件的精神以及其给予用户的众多选择而闻名现时 `Debian` 包括了超过 `25,000` 个软件包并支持 `12` 个计算机系统结构
`Debian` 作为一个大的系统组织框架其下有多种不同操作系统核心的分支计划主要为采用 `Linux` 核心的 `Debian GNU/Linux` 系统其他还有采用 `GNU Hurd` 核心的 `Debian GNU/Hurd` 系统采用 `FreeBSD` 核心的 `Debian GNU/kFreeBSD` 系统以及采用 `NetBSD` 核心的 `Debian GNU/NetBSD` 系统甚至还有利用 `Debian` 的系统架构和工具采用 `OpenSolaris` 核心构建而成的 `Nexenta OS` 系统在这些 `Debian` 系统中以采用 `Linux` 核心的 `Debian GNU/Linux` 最为著名
众多的 `Linux` 发行版例如 `Ubuntu``Knoppix` `Linspire` `Xandros` 都基于 `Debian GNU/Linux`
### 使用 Debian 官方镜像
官方提供了大家熟知的 `debian` 镜像以及面向科研领域的 `neurodebian` 镜像可以使用 `docker run` 直接运行 `Debian` 镜像
```bash
$ docker run -it debian bash
root@668e178d8d69:/# cat /etc/issue
Debian GNU/Linux 8
```
`Debian` 镜像很适合作为基础镜像构建自定义镜像
## Ubuntu 系统简介
![Ubuntu 操作系统](../../_images/ubuntu-logo.jpg)
`Ubuntu` 是一个以桌面应用为主的 `GNU/Linux` 操作系统其名称来自非洲南部祖鲁语或豪萨语的ubuntu一词官方译名友帮拓另有吾帮托乌班图有奔头乌斑兔等译名`Ubuntu` 意思是人性以及我的存在是因为大家的存在是非洲传统的一种价值观类似华人社会的仁爱思想 `Ubuntu` 基于 `Debian` 发行版和 `GNOME/Unity` 桌面环境 `Debian` 的不同在于它每 6 个月会发布一个新版本 2 年推出一个长期支持 **Long Term SupportLTS** 版本一般支持 3 年时间
### 使用 Ubuntu 官方镜像
下面以 `ubuntu:24.04` 为例演示如何使用该镜像安装一些常用软件
首先使用 `-ti` 参数启动容器登录 `bash`查看 `ubuntu` 的发行版本号
```bash
$ docker run -ti ubuntu:24.04 /bin/bash
root@7d93de07bf76:/# cat /etc/os-release
PRETTY_NAME="Ubuntu 24.04 LTS"
NAME="Ubuntu"
VERSION_ID="24.04"
VERSION="24.04 LTS (Noble Numbat)"
VERSION_CODENAME=noble
ID=ubuntu
ID_LIKE=debian
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
```
当试图直接使用 `apt-get` 安装一个软件的时候会提示 `E: Unable to locate package`
```bash
root@7d93de07bf76:/# apt-get install curl
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
E: Unable to locate package curl
```
这并非系统不支持 `apt-get` 命令Docker 镜像在制作时为了精简清除了 `apt` 仓库信息因此需要先执行 `apt-get update` 命令来更新仓库信息更新信息后即可成功通过 `apt-get` 命令来安装软件
```bash
root@7d93de07bf76:/# apt-get update
Get:1 http://archive.ubuntu.com/ubuntu noble InRelease [256 kB]
Get:2 http://security.ubuntu.com/ubuntu noble-security InRelease [126 kB]
...
Fetched 25.8 MB in 8s (3215 kB/s)
Reading package lists... Done
```
首先安装 `curl` 工具
```bash
root@7d93de07bf76:/# apt-get install curl
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
ca-certificates krb5-locales libasn1-8-heimdal libcurl4 libgssapi-krb5-2 libgssapi3-heimdal libhcrypto4-heimdal libheimbase1-heimdal libheimntlm0-heimdal libhx509-5-heimdal
libk5crypto3 libkeyutils1 libkrb5-26-heimdal libkrb5-3 libkrb5support0 libldap-2.4-2 libldap-common libnghttp2-14 libpsl5 libroken18-heimdal librtmp1 libsasl2-2 libsasl2-modules libsasl2-modules-db libsqlite3-0 libssl1.1 libwind0-heimdal openssl publicsuffix
...
root@7d93de07bf76:/# curl
curl: try 'curl --help' or 'curl --manual' for more information
```
接下来再安装 `apache` 服务
```bash
root@7d93de07bf76:/# apt-get install -y apache2
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
apache2-bin apache2-data apache2-utils file libapr1 libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap libexpat1 libgdbm-compat4 libgdbm5 libicu60 liblua5.2-0 libmagic-mgc libmagic1 libperl5.26 libxml2 mime-support netbase perl perl-modules-5.26 ssl-cert xz-utils
...
```
启动这个 `apache` 服务然后使用 `curl` 来测试本地访问
```bash
root@7d93de07bf76:/# service apache2 start
* Starting web server apache2 AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.17.0.2. Set the 'ServerName' directive globally to suppress this message
*
root@7d93de07bf76:/# curl 127.0.0.1
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<!--
Modified from the Debian original for Ubuntu
Last updated: 2016-11-16
See: https://launchpad.net/bugs/1288690
-->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Apache2 Ubuntu Default Page: It works</title>
<style type="text/css" media="screen">
...
```
配合使用 `-p` 参数对外映射服务端口可以允许容器外来访问该服务
## 相关资源
* `Debian` 官网https://www.debian.org/
* `Neuro Debian` 官网http://neuro.debian.net/
* `Debian` 官方仓库https://github.com/Debian
* `Debian` 官方镜像https://hub.docker.com/\_/debian/
* `Debian` 官方镜像仓库https://github.com/tianon/docker-brew-debian/
* `Ubuntu` 官网https://ubuntu.com
* `Ubuntu` 官方仓库https://github.com/ubuntu
* `Ubuntu` 官方镜像https://hub.docker.com/\_/ubuntu/
* `Ubuntu` 官方镜像仓库https://github.com/tianon/docker-brew-ubuntu-core