Home > OS >  How do I set the Name of an Container in Docker.DotNet?
How do I set the Name of an Container in Docker.DotNet?

Time:12-25

So I have this call, which starts a container:

await _client.Containers.CreateContainerAsync(new CreateContainerParameters()
            {
                Image = environment.DockerImage,

            });

How or better said where do I set the name of the conainer

I've tried giving it an extra Parameter, like this:

            await _client.Containers.CreateContainerAsync(Bootstrap.Get().Agent.ConfigManager.ContainerPrefix,new CreateContainerParameters()
            {
                Image = environment.DockerImage,

            });

but this doesn't work

CodePudding user response:

Try

await _client.Containers.CreateContainerAsync(new CreateContainerParameters()
            {
                Image = environment.DockerImage,
                Name = "my_container"
            });

You can see all the properties in CreateContainerParameters here.

  • Related