可以修改,可以在创建容器时通过指定HostConfig来修改容器的配置。例如:

hostConfig := &container.HostConfig{
    // 设置容器的资源限制
    Resources: container.Resources{
        Memory: 1024 * 1024 * 1024, // 1GB
        CPUShares: 512,
    },
    // 设置容器的网络配置
    NetworkMode: container.NetworkMode("bridge"),
    // 设置容器的挂载点
    Mounts: []mount.Mount{
        {
            Type:   mount.TypeBind,
            Source: "/host/path",
            Target: "/container/path",
        },
    },
}

container, err := cli.ContainerCreate(ctx, config, hostConfig, nil, "my-container")
if err != nil {
    log.Fatal(err)
}
``
golang docker中的HostConfig配置没办法修改吗

原文地址: https://www.cveoy.top/t/topic/djyh 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录