I would like to mount a local directory when using the golang SDK
I’m following the documentation
resp, err := cli.ContainerCreate(ctx, &container.Config{
Image: “alpine”,
Cmd: string{“echo”, “hello world”},
}, nil, nil, “”)
Volumes is part of the containerConfig but I’m not sure how to define the source directory (from the local host) to the target directory (on the container)
type Config struct {
…
Volumes map[string]struct{} // List of volumes (mounts) used for the container
…
}
Can someone share an example of how to create a container and mount a local volume?
resp, err := cli.ContainerCreate(ctx, &container.Config{
Image: “alpine”,
Cmd: string{“echo”, “hello world”},
Volumes: map[string]struct{}{“/opt/”: {}}, #???
}, nil, nil, “”)
Thanks!!