Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Config.Volumes Usage #132

Closed
zealws opened this issue Jul 30, 2014 · 4 comments
Closed

Config.Volumes Usage #132

zealws opened this issue Jul 30, 2014 · 4 comments

Comments

@zealws
Copy link

zealws commented Jul 30, 2014

I'm trying to create a new container using the CreateContainer method.

I want the container to mount a directory on the host inside the container, just like using the docker run -v /xyz:/abc format.

I've been looking at the Config type's Volumes field and can't figure out the appropriate value for the struct{} as the value type of the map.

I've tried passing in a variety of parameters for it, and none of them seem to work.

Is there some working sample code somewhere for how to pass in the values for Config.Volumes?

@fgrehm
Copy link
Contributor

fgrehm commented Jul 30, 2014

I believe that shared volumes are specified with the StartContainer method along with its HostConfig and its Binds option.

Not sure if it is the right way to do it but least that was how I made it work :-)

@zealws
Copy link
Author

zealws commented Jul 31, 2014

I see, thanks. Some more detailed documentation would be nice, but examples suffice for what I'm trying to do.

Also, the official Docker documentation is sorely lacking in this area, so I don't necessarily think it's the client's responsibility to document it.

@zealws zealws closed this as completed Jul 31, 2014
@fsouza
Copy link
Owner

fsouza commented Jul 31, 2014

@zfjagann no problem, it's a common source of confusion. People is used to call docker run, which in the API represents at least two calls: create + start.

We need to improve the examples that we have in the source, that is used both for documentation and to keep our API ok. Currently, we have only examples for AttachToContainer, BuildImage and CopyFromContainer.

@deepak6446
Copy link

may be useful for someone

resp, err := cli.ContainerCreate(ctx, &container.Config{
Tty: false,
Image: "fb05ad264203",
Env: []string{"port="+port},
}, &container.HostConfig{
PidMode: "host",
NetworkMode: "host",
UTSMode: "host",
Resources: container.Resources{
Memory: 100000000,
MemorySwap: 100000000,
},
Binds:[]string{
HOST.TEMP_PATH + ":" + DOCKER.TEMP_PATH + ":rw",
HOST.CONNECTOR_PATH + ":" + DOCKER.CONNECTOR_PATH + ":ro",
HOST.CLI_CONNECTORS + ":" + DOCKER.CLI_CONNECTORS + ":ro",
},
}, nil, "")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants