Closed aminjam closed 7 years ago
I had the same problem with volumes. Here's an example based on https://github.com/drone/drone/blob/c613571bd641ce96b7bb80bf6395e561d3feb6aa/engine/runner/docker/util.go
var binds []string
volumes := map[string]struct{}{}
// Set up a map where key is host dir and the value is the name on the container
volumeDefinitions := make(map[string]string)
volumeDefinitions["/Users/odewahn/Desktop/interferometry-demo"] = "/mymac"
for hostPath, containerPath := range volumeDefinitions {
binds = append(binds, hostPath+":"+containerPath)
volumes[containerPath] = struct{}{}
}
// Define Binds in the HostConfig
hostConfig := &dockerclient.HostConfig{
Binds: binds,
}
// Define volumes in the ContainerConfig
containerConfig := &dockerclient.ContainerConfig{
Image: "odewahn/interferometry-demo",
Volumes: volumes,
AttachStdin: true,
Tty: true}
// Create the container
containerID, err := docker.CreateContainer(containerConfig, "foobar", nil)
I am looking for an example of using
--volume
withContainerConfig
. I see there is aVolumes map[string]struct{}
inContainerConfig
, but how do I use it?Also I can't find any example for using
-e
option. I have tried settingEnv
array item to beNAME=AJ
. What should be the format forEnv
slice inContainerConfig
?