Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Strange behavior building an image #262

Open
orelvis15 opened this issue Oct 8, 2022 · 3 comments
Open

Strange behavior building an image #262

orelvis15 opened this issue Oct 8, 2022 · 3 comments

Comments

@orelvis15
Copy link

orelvis15 commented Oct 8, 2022

Hello Goodnight!.
I am testing an example of the slightly modified lib it would be running like this.

    build_image_args.insert("version_url", versionNumber.as_str());
    build_image_args.insert("version_number", versionUrl.as_str());

    let build_image_options = BuildImageOptions {
        remote: dockerfileUrl.as_str(), //url to a regular Dockerfile
        buildargs: build_image_args,
        ..Default::default()
    };

    let mut image_build_stream = docker.build_image(build_image_options, None, None);

    while let Some(msg) = image_build_stream.next().await {
        println!("Message: {:?}", msg);
    }

Dockerfile

When executing this code, an unusual behavior begins, first two images are created, one with the name Ubuntu and the other None, then containers are created up to a total of 21.

I leave the captures of how the final result looks.

Captura de Pantalla 2022-10-07 a la(s) 23 00 49

Captura de Pantalla 2022-10-07 a la(s) 23 01 05

And these are the two images created.
Captura de Pantalla 2022-10-07 a la(s) 23 01 48
Captura de Pantalla 2022-10-07 a la(s) 23 01 58

Docker version

Captura de Pantalla 2022-10-08 a la(s) 11 50 15

Any idea what my mistake would be?

@fussybeaver
Copy link
Owner

Could you explain your motivation or what you're trying to achieve? I don't see any problem yet...

@orelvis15
Copy link
Author

Of course, what happens is that when you create an image using that dockerfile using the terminal, the corresponding image is created, including prove using the std:: process of rust and everything is ok, but when I do it using the lib, the behavior that it creates comes out two images and 21 containers which is not what I'm expecting, it should only create 1 single image without containers because I'm just building the image

@leon3s
Copy link
Contributor

leon3s commented Dec 16, 2022

Hey @orelvis15 this is not an issue related to bollard. Container image are created using container. You have one container running for each command you set in your dockerfile. by default when you build using the docker cli it will remove them, when you use the API dirrectly you have to specify an option to delete them.
Look there https://docs.docker.com/engine/api/v1.41/#tag/Image/operation/ImageBuild
You will notice 2 options:

  • rm Remove intermediate containers after a successful build.
  • forcerm Always remove intermediate containers, even upon failure.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants