0%

使用Podman替代DockerDesktop

  1. 安装依赖环境

    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 /noresart

    wsl --install
    wsl --update
  2. 安装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
  3. 测试

    1
    docker run --rm -d -p 80:80 --name httpd docker.io/library/httpd:latest
  4. 配置镜像加速
    podman的配置文件在容器内 /etc/containers/registries.conf,配置格式如下

    1
    2
    3
    4
    5
    unqualified-search-regustrues = ["docker.io"]

    [[registry]] # 注意此处配置不需要加'https'
    prefix = "docker.io" # 访问地址
    location = "docker.m.daocloud.io" # 加速地址
  5. 配置私有镜像库

1
2
3
[[registry."harbor.example.io"]]
tlsVerify = true
tls = "ca file path"