fussybeaver / bollard

Docker daemon API in Rust
Apache License 2.0
907 stars 134 forks source link

None container_config? #451

Open ilteoood opened 3 months ago

ilteoood commented 3 months ago

Hi, I'm actually inspecting the image: ilteoood/xdcc-mule.

This is the outcome that I see (Mac M3 Pro):

[
    {
        "Id": "sha256:711c326f10e4be88f280bac77217fd12236994f971c15b762f74094d305b2f0f",
        "RepoTags": [
            "ilteoood/xdcc-mule:latest"
        ],
        "RepoDigests": [
            "ilteoood/xdcc-mule@sha256:5007a598514cc3d2f2fdc3caa0ad2936e2022765cf26d266822f09cfb78c6d19"
        ],
        "Parent": "",
        "Comment": "buildkit.dockerfile.v0",
        "Created": "2024-08-12T03:06:55.179402508Z",
        "DockerVersion": "",
        "Author": "",
        "Config": {
            "Hostname": "",
            "Domainname": "",
            "User": "",
            "AttachStdin": false,
            "AttachStdout": false,
            "AttachStderr": false,
            "ExposedPorts": {
                "3000/tcp": {}
            },
            "Tty": false,
            "OpenStdin": false,
            "StdinOnce": false,
            "Env": [
                "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
                "NODE_VERSION=20.16.0",
                "YARN_VERSION=1.22.22"
            ],
            "Cmd": null,
            "ArgsEscaped": true,
            "Image": "",
            "Volumes": null,
            "WorkingDir": "/app",
            "Entrypoint": [
                "node",
                "index.js"
            ],
            "OnBuild": null,
            "Labels": null
        },
        "Architecture": "arm64",
        "Os": "linux",
        "Size": 334296326,
        "GraphDriver": {
            "Data": {
                "LowerDir": "/var/lib/docker/overlay2/3f11fadf42a17400969d79b447c686d120aa74eefdf767caef6b817bbc3dd5d1/diff:/var/lib/docker/overlay2/d67edc17100663d681e22c5b436918082a5fd5788c9859716580682ba0076708/diff:/var/lib/docker/overlay2/9f2db337254096d94710f9ee1b5d4b5ead023f7764825f4a612dca52386de05d/diff:/var/lib/docker/overlay2/2dd5736794d86d7159b85b7dd012d4688f35fc826c2ac339f1930e8fab88d41d/diff:/var/lib/docker/overlay2/bae73af8cd0e65e2f315d2c6ac2217b9f4bffdfae98f67c4cd66d51056187860/diff:/var/lib/docker/overlay2/3deffd6e2de897f007cd7ee0a181aafaf3016c2886c3d6c7b9e9f2c68faa8cec/diff:/var/lib/docker/overlay2/39079dad547ac418cf7016febde04f274710fb3f46515df3877f352e5f907791/diff:/var/lib/docker/overlay2/7b4341c8c94786084499855b62f2888328408c9f4b43c71b7fe0d463ca5fc727/diff",
                "MergedDir": "/var/lib/docker/overlay2/c1e6e9df34003d574af7713c90c628493c18eec243605bba5e7bcf2202a88419/merged",
                "UpperDir": "/var/lib/docker/overlay2/c1e6e9df34003d574af7713c90c628493c18eec243605bba5e7bcf2202a88419/diff",
                "WorkDir": "/var/lib/docker/overlay2/c1e6e9df34003d574af7713c90c628493c18eec243605bba5e7bcf2202a88419/work"
            },
            "Name": "overlay2"
        },
        "RootFS": {
            "Type": "layers",
            "Layers": [
                "sha256:9110f7b5208f035f4d4f99b5169338169e1df9bb2519d1b047f50f54430bacc2",
                "sha256:93e482f641cc9e28edb0f0255db611c423d8d8ffb182851fea4a3d11cca57809",
                "sha256:e99643da769bc5762eb1b3411474bc7c07e7456d3d45dfcf8da332410050cba8",
                "sha256:72deda6891f4fafcf2af6a1576cc82d7ed564674ebb6ab110624ffb188f049a5",
                "sha256:a31f53d8ecdd2e99d386de8db6fdaa9d81c3adb1aa554a7607cb26936b577a9c",
                "sha256:bd06ce6c63c21436edfa5e042291044b1bd2fe565c2303ebeb25762606005601",
                "sha256:306ba62d1c9f9103f11368a3c828941346b0498569decc24f7dace4935d9f081",
                "sha256:7f8398fd73c732d978a16f4a9318e69b0f7a84bfa4997c4db4790ae61154d304",
                "sha256:62c571bac6977855020d6f1c7975b0c47f52f7029e420d939e8798955f898ba0"
            ]
        },
        "Metadata": {
            "LastTagTime": "0001-01-01T00:00:00Z"
        }
    }
]

As you can see, the Config object has some fields that I'm trying to read using the following code:

async fn retrieve_config(
    docker: &Docker,
    configurations: &DockerConfigurations,
) -> Result<ContainerConfigurations, bollard::errors::Error> {
    let source_image = configurations.source_image.as_str();
    pull_image(docker, source_image).await;

    let inspect = docker.inspect_image(source_image).await?;

    match inspect.container_config {
        Some(container_config) => Ok(ContainerConfigurations::from_container(container_config)),
        None => Ok(ContainerConfigurations::new()),
    }
}

However, both config and container_config seems to be None. Am I missing something? image

ilteoood commented 3 months ago

Sorry, I don't know why but config is now available. Can I ask then what container_config does? It has the same shape as config.

fussybeaver commented 3 months ago

No idea... this is the type returned from the inspect container API: https://docs.rs/bollard-stubs/1.45.0-rc.26.0.1/bollard_stubs/models/struct.ContainerInspectResponse.html .. there is no mention of a container_config