bollard icon indicating copy to clipboard operation
bollard copied to clipboard

Issue with Config when creating a container

Open arthmis opened this issue 4 years ago • 0 comments

In order to create a container you need to use the Config struct like so:

    let create_container_config: Config<String> = Config {
        image: Some("some_image".to_string()),
        ..Default::default()
    };
    let res = docker
        .create_container(
            Some(CreateContainerOptions { name: "test" }),
            create_container_config,
        )
        .await
        .unwrap();

The issue I had was when I tried to use

    let create_container_config: Config<String> = Config {
        ..Default::default()
    };

I tried to create a container with the default initialization, however the create_container function failed because of the error:

thread 'main' panicked at 'called `Result::unwrap()` on an 
`Err` value: DockerResponseBadParameterError { 
    message: "{\"message\":\"Config cannot be empty in order to create a container\"}" 
}'

So i assumed this to mean that the image name is required when configuring to create a container. Maybe I'm missing other ways to create a container with the Config, but maybe the image field should not be Option<T> and should be required.

arthmis avatar Dec 04 '20 21:12 arthmis