bollard
bollard copied to clipboard
Issue with Config when creating a container
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.