Skip to content

Commit

Permalink
Merge pull request #7 from jgarverick/NamedContainers
Browse files Browse the repository at this point in the history
Adding support for naming a container when using CreateContainer
  • Loading branch information
Ahmet Alp Balkan committed Oct 7, 2014
2 parents b8390f9 + 2b3ca06 commit 044ac99
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
8 changes: 7 additions & 1 deletion Docker.DotNet/ContainerOperations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,18 +54,24 @@ public async Task<ContainerResponse> InspectContainerAsync(string id)

public async Task<CreateContainerResponse> CreateContainerAsync(CreateContainerParameters parameters)
{
IQueryString qs = null;

if (parameters == null)
{
throw new ArgumentNullException("parameters");
}

if (!string.IsNullOrEmpty(parameters.ContainerName)) {
qs = new QueryString<CreateContainerParameters>(parameters);
}

string path = "containers/create";
JsonRequestContent<Config> data = null;
if (parameters.Config != null)
{
data = new JsonRequestContent<Config>(parameters.Config, this.Client.JsonSerializer);
}
DockerApiResponse response = await this.Client.MakeRequestAsync(new[] {NoSuchContainerHandler}, HttpMethod.Post, path, null, data);
DockerApiResponse response = await this.Client.MakeRequestAsync(new[] {NoSuchContainerHandler}, HttpMethod.Post, path, qs, data);
return this.Client.JsonSerializer.DeserializeObject<CreateContainerResponse>(response.Body);
}

Expand Down
3 changes: 3 additions & 0 deletions Docker.DotNet/Models/CreateContainerParameters.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ public class CreateContainerParameters
{
public Config Config { get; set; }

[QueryStringParameter("name", false)]
public string ContainerName { get; set; }

public CreateContainerParameters()
{
}
Expand Down

0 comments on commit 044ac99

Please sign in to comment.