dongzhi5846
dongzhi5846
2019-01-14 07:11

使用docker golang库的卷挂载选项'z'

已采纳

How to pass z flag for volume mount using docker golang library ? For supporting Selinux

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

1条回答

  • dongmi1941 dongmi1941 2年前

    I would think you can just add ':z' to the path of the volume, which is a string:

    res, err := client.ContainerCreate(
        ctx,
        &container.Config{
            Image: "nginx",
            Cmd:   []string{},
        },
        &container.HostConfig{
            Mounts: []mount.Mount{
                {
                    Type:   mount.TypeVolume,
                    Source: "/app:z",   // <---- HERE
                    Target: "/target",
                },
            },
        },
        nil,
        "",
    )
    
    点赞 评论 复制链接分享