Define the mount point of the volume in GoLangDockerSDK

I’m currently trying to create a Docker container using the official GoLang Docker SDK and trying to mount a volume from my localhost to the Docker container. vol := map[string]struct{}{“/pathInDocker”:{}} // This was prepared using example at: //https://docs.docker.com/develop/sdk/examples/#run-a-container res, err := cli.ContainerCreate(ctx, &container.Config{ Image: testImageName, Volumes: vol, Cmd: []string{“ls”, “/”}, }, nil, nil, “”) This works when I create the container and add “/pathInDocker” to the docker container, however, I can’t figure out how to add a mount point for localhost. I have tried the following possible values ​​for the vol variable vol := map[string]struct{}{“localPath:/pathInDocker”:{}} vol := map[string]struct{}{“\”localPath\”:\”/pathInDocker\””:{}} For each of these, the final docker container attempts to mount the map key as a folder within docker, without a mount point for localhost. I’ve looked through the documentation and the only thing I can seem to find about how to configure volumes is: Volumes map[string]struct{} // List of volumes (mounts) used for the container So my question is how do I configure it so that a local folder is mounted to that volume? 1> aerokite..: If you want to use bind installation, you need to provide the installation in HostConfig information. res, err := client.ContainerCreate( ctx, &container.Config{ Image: “nginx”, Cmd:…

Contact Us

Contact us

181-3619-1160

Online consultation: QQ交谈

E-mail: 34331943@QQ.com

Working hours: Monday to Friday, 9:00-17:30, holidays off

Follow wechat
Scan wechat and follow us

Scan wechat and follow us

Follow Weibo
Back to top
首页
微信
电话
搜索