fussybeaver / bollard

Docker daemon API in Rust

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Creating a container

MoskalykA opened this issue · comments

Hi,
I would like to know if there is a function to create a container from an image and specifying the version of this image?

commented

Yeah ofc

use bollard::container::{CreateContainerOptions, Config};

use std::default::Default;

let options = Some(CreateContainerOptions{
    name: "my-new-container",
});

let config = Config {
    image: Some("hello-world:some_version"),
    cmd: Some(vec!["/hello"]),
    ..Default::default()
};

docker.create_container(options, config);

I suggest you to take a look at the documentation

Yeah ofc

use bollard::container::{CreateContainerOptions, Config};

use std::default::Default;

let options = Some(CreateContainerOptions{
    name: "my-new-container",
});

let config = Config {
    image: Some("hello-world:some_version"),
    cmd: Some(vec!["/hello"]),
    ..Default::default()
};

docker.create_container(options, config);

I suggest you to take a look at the documentation

Thanks 👍🏻