fussybeaver / bollard

Docker daemon API in Rust

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Missing 'pull' option in `Docker::create_container`

ClementNerma opened this issue · comments

Hi!

It seems like the pull option is missing from the Docker::create_container method.

As per Docker's documentation, this option can either be always, missing or never.

EDIT: I checked Docker's API reference and it seems like the pull option only exists in the CLI, which is really weird.

I guess that means you need to create an image in order to create a container (if you don't execute it immediately)? This is weird.

Yes, the docker CLI does a few extra things. To pull an image you use create_image.

I've tried that I keep getting the following error:

Docker responded with status code 400: invalid reference format: repository name must be lowercase

When the image is just crccheck/hello-world (I've also tried with crccheck/hello-world:latest)

EDIT: The entire call is as follows:

        docker.create_image(
            Some(CreateImageOptions {
                from_image: "crccheck/hello-world",
                ..Default::default()
            }),
            None,
            None,
        )
        .try_collect::<Vec<_>>()
        .await?

EDIT: The example provided in this repository (https://github.com/fussybeaver/bollard/blob/master/examples/exec.rs) works correctly. I don't get what I'm doing wrong since I use the exact same method to pull the image...

Ok so I'm plain stupid, the exact code I was using was reading the image name from a variable, and I used the one containing the container's name instead of its image 🤦

Sorry for the inconvenience.