I am trying to run docker inside container using Go Docker Engine API. I am able to mount a folder from host system to the container but only empty dir is being copied into the docker inside the container. Please help me out if there is any alternative for the same. I am starting my container using following command.
docker run --rm -v C:\Users\user\source\repos\game:/app/myrepo -v /var/run/docker.sock:/var/run/docker.sock testimage
Attached is the piece of code. Go Docker SDK code to start container
resp, err := cli.ContainerCreate(ctx, &container.Config{
Image: "hello-image",
Cmd: []string{"ls"}, #the actual cmd would look different
Tty: true,
}, &container.HostConfig{
Binds: []string{
"/app/myrepo:/myrepo",
},
}, nil, nil, containername)
if err != nil {
panic(err)
}
updated Code for binds with absolute path
resp, err := cli.ContainerCreate(ctx, &container.Config{
Image: "hello-image",
Cmd: []string{"ls"}, #the actual cmd would look different
Tty: true,
}, &container.HostConfig{
Mounts: []mount.Mount{
{
Type: mount.TypeBind,
Source: "/app/myrepo",
Target: "/myrepo",
},
},
}, nil, nil, containername)
if err != nil {
panic(err)
}