diff --git a/Docker.DotNet/ContainerOperations.cs b/Docker.DotNet/ContainerOperations.cs index 235800487..26401bd31 100644 --- a/Docker.DotNet/ContainerOperations.cs +++ b/Docker.DotNet/ContainerOperations.cs @@ -54,18 +54,24 @@ public async Task InspectContainerAsync(string id) public async Task CreateContainerAsync(CreateContainerParameters parameters) { + IQueryString qs = null; + if (parameters == null) { throw new ArgumentNullException("parameters"); } + if (!string.IsNullOrEmpty(parameters.ContainerName)) { + qs = new QueryString(parameters); + } + string path = "containers/create"; JsonRequestContent data = null; if (parameters.Config != null) { data = new JsonRequestContent(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(response.Body); } diff --git a/Docker.DotNet/Models/CreateContainerParameters.cs b/Docker.DotNet/Models/CreateContainerParameters.cs index 831c1f57b..eb363d189 100644 --- a/Docker.DotNet/Models/CreateContainerParameters.cs +++ b/Docker.DotNet/Models/CreateContainerParameters.cs @@ -4,6 +4,9 @@ public class CreateContainerParameters { public Config Config { get; set; } + [QueryStringParameter("name", false)] + public string ContainerName { get; set; } + public CreateContainerParameters() { }