安装依赖环境
1
2
3
4
5
6
7
8# 启用虚拟化平台
dism /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
# 启用linux子系统
dism /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all
wsl --install
wsl --update安装Podman
1
2
3
4
5
6
7
8
9
10
11
12
13
14# 安装DockerCLI,用于兼容Docker命令
winget install --id Docker.DockerCLI
# 安装Podman
winget install --id RedHat.Podman
# 安装Podman Desktop (可选)
winget install --id RedHat.Podman-Desktop
# 初始化Podman
podman machine init
# 配置端口转发
wsl sudo sysctl net.ipv4.ip_forward=1配置wsl虚拟机
1
2
3
4
5
6
7# 修改默认软件源
sudo sed -e 's|^metalink=|#metalink=|g' \
-e 's|^#baseurl=http://download.example/pub/fedora/linux|baseurl=https://mirrors.tuna.tsinghua.edu.cn/fedora|g' \
-i.bak \
/etc/yum.repos.d/fedora.repo \
/etc/yum.repos.d/fedora-updates.repo
sudo dnf makecache测试
1
docker run --rm -d -p 80:80 --name httpd docker.io/library/httpd:latest
配置镜像加速
podman的配置文件在容器内/etc/containers/registries.conf
,配置格式如下1
2
3
4
5unqualified-search-regustrues = ["docker.io"]
[[registry]] # 注意此处配置不需要加'https'
prefix = "docker.io" # 访问地址
location = "docker.m.daocloud.io" # 加速地址配置私有镜像库
1 | [[registry]] |
如果访问地址为https
需要配置信任证书
1 | sudo mkdir /etc/containers/certs.d |
- 配置文件翻译
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68# 有关此配置文件的更多信息,请参阅 containers-registries.conf(5)。
#
# 注意:使用未完全限定镜像名称的风险
# 我们建议始终使用包括注册表服务器(完整 DNS 名称)、命名空间、镜像名称和标签在内的完全限定镜像名称
# (例如,registry.redhat.io/ubi8/ubi:latest)。通过摘要(例如,
# quay.io/repository/name@digest)拉取镜像可以进一步消除标签的不确定性。
# 使用短名称时,始终存在镜像被伪造的风险。例如,用户想从某个注册表中拉取名为
# `foobar` 的镜像,并期望该镜像来自 myregistry.com。如果
# myregistry.com 不是搜索列表中的第一个,攻击者可能会在列表中靠前的位置
# 放置另一个名为 `foobar` 的镜像。用户可能会意外拉取并运行攻击者的镜像和代码,而不是
# 预期的内容。我们建议只添加完全可信的注册表(即,不允许未知或匿名用户
# 创建任意名称的账户的注册表)。这将防止镜像被伪造、抢占或以其他方式变得不安全。
# 如果有必要使用这些注册表,它应该添加到列表的末尾。
#
# # 一个主机[:端口]格式的注册表数组,当拉取未完全限定镜像时,按顺序尝试这些注册表。
unqualified-search-registries = ["registry.fedoraproject.org", "registry.access.redhat.com", "docker.io"]
#
# [[registry]]
# # "prefix" 字段用于选择相关的 [[registry]] TOML 表;
# # 使用输入镜像名称时,只有与该名称最长匹配的 TOML 表会被使用
# # (考虑到命名空间/库/标签/摘要分隔符)。
# #
# # 如果缺少 prefix 字段,则默认与 "location" 字段相同。
prefix = "example.com/foo"
#
# # 如果为 true,则允许未加密的 HTTP 连接以及使用不受信任证书的 TLS 连接。
insecure = false
#
# # 如果为 true,则禁止拉取匹配名称的镜像。
blocked = false
#
# # "prefix" 所在命名空间的物理位置。
# #
# # 默认情况下,与 "prefix" 相同(在这种情况下,可以省略 "prefix",并且 [[registry]] TOML 表只指定 "location")。
# #
# # 例如:假设
# # prefix = "example.com/foo"
# # location = "internal-registry-for-example.net/bar"
# # 那么对镜像 example.com/foo/myimage:latest 的请求实际上会与
# # internal-registry-for-example.net/bar/myimage:latest 镜像匹配。
location = "internal-registry-for-example.com/bar"
#
# # "prefix" 所在命名空间的(可能部分的)镜像。
# #
# # 将按指定顺序尝试这些镜像;第一个可以联系到并包含镜像的将被使用
# # (如果所有镜像都没有该镜像,则最后尝试 "registry.location" 字段指定的主位置,或者使用未修改的用户指定引用)。
# #
# # "mirror" 数组中的每个 TOML 表可以包含以下字段,语义与直接在 [[registry]] TOML 表中指定的相同:
# # - location
# # - insecure
[[registry.mirror]]
location = "example-mirror-0.local/mirror-for-foo"
[[registry.mirror]]
location = "example-mirror-1.local/mirrors/foo"
insecure = true
# # 根据上述配置,拉取 example.com/foo/image:latest 时将按顺序尝试:
# # 1. example-mirror-0.local/mirror-for-foo/image:latest
# # 2. example-mirror-1.local/mirrors/foo/image:latest
# # 3. internal-registry-for-example.net/bar/image:latest
# # 并使用第一个存在的镜像。
#
# short-name-mode="enforcing"
# 强制使用完全限定镜像名称
[[registry]]
location="localhost:5000"
insecure=true
# 允许使用不安全的连接拉取本地镜像。