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

add platform parameter for create_container #259

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions examples/kafka.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,10 @@ async fn main() -> Result<(), Box<dyn std::error::Error + 'static>> {

let _ = &docker
.create_container(
Some(CreateContainerOptions { name: "zookeeper" }),
Some(CreateContainerOptions {
name: "zookeeper",
platform: None,
}),
zookeeper_config,
)
.await?;
Expand All @@ -98,7 +101,10 @@ async fn main() -> Result<(), Box<dyn std::error::Error + 'static>> {

let _ = &docker
.create_container(
Some(CreateContainerOptions { name: "kafka1" }),
Some(CreateContainerOptions {
name: "kafka1",
platform: None,
}),
broker1_config,
)
.await?;
Expand Down Expand Up @@ -131,7 +137,10 @@ async fn main() -> Result<(), Box<dyn std::error::Error + 'static>> {

let _ = &docker
.create_container(
Some(CreateContainerOptions { name: "kafka2" }),
Some(CreateContainerOptions {
name: "kafka2",
platform: None,
}),
broker2_config,
)
.await?;
Expand Down
7 changes: 7 additions & 0 deletions src/container.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ where
///
/// CreateContainerOptions{
/// name: "my-new-container",
/// platform: Some("linux/amd64"),
/// };
/// ```
#[derive(Debug, Clone, Default, PartialEq, Serialize)]
Expand All @@ -97,6 +98,11 @@ where
{
/// Assign the specified name to the container.
pub name: T,

/// The platform to use for the container.
/// Added in API v1.41.
#[serde(skip_serializing_if = "Option::is_none")]
pub platform: Option<T>,
}

/// This container's networking configuration.
Expand Down Expand Up @@ -1208,6 +1214,7 @@ impl Docker {
///
/// let options = Some(CreateContainerOptions{
/// name: "my-new-container",
/// platform: None,
/// });
///
/// let config = Config {
Expand Down
3 changes: 3 additions & 0 deletions tests/common/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ pub async fn create_container_hello_world(
.create_container(
Some(CreateContainerOptions {
name: container_name.to_string(),
platform: None,
}),
Config {
cmd,
Expand Down Expand Up @@ -164,6 +165,7 @@ pub async fn create_shell_daemon(
.create_container(
Some(CreateContainerOptions {
name: container_name,
platform: None,
}),
Config {
image: Some(image),
Expand Down Expand Up @@ -227,6 +229,7 @@ pub async fn create_daemon(docker: &Docker, container_name: &'static str) -> Res
.create_container(
Some(CreateContainerOptions {
name: container_name,
platform: None,
}),
Config {
cmd,
Expand Down
2 changes: 2 additions & 0 deletions tests/container_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -573,6 +573,7 @@ async fn archive_container_test(docker: Docker) -> Result<(), Error> {
.create_container(
Some(CreateContainerOptions {
name: "integration_test_archive_container",
platform: None,
}),
Config {
image: Some(&image[..]),
Expand Down Expand Up @@ -727,6 +728,7 @@ async fn mount_volume_container_test(docker: Docker) -> Result<(), Error> {
.create_container(
Some(CreateContainerOptions {
name: "integration_test_mount_volume_container",
platform: None,
}),
Config {
image: Some(&image[..]),
Expand Down
3 changes: 3 additions & 0 deletions tests/image_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ async fn commit_container_test(docker: Docker) -> Result<(), Error> {
.create_container(
Some(CreateContainerOptions {
name: "integration_test_commit_container",
platform: None,
}),
Config {
cmd,
Expand Down Expand Up @@ -212,6 +213,7 @@ async fn commit_container_test(docker: Docker) -> Result<(), Error> {
.create_container(
Some(CreateContainerOptions {
name: "integration_test_commit_container_next",
platform: None,
}),
Config {
image: Some("integration_test_commit_container_next"),
Expand Down Expand Up @@ -329,6 +331,7 @@ RUN touch bollard.txt
.create_container(
Some(CreateContainerOptions {
name: "integration_test_build_image",
platform: None,
}),
Config {
image: Some("integration_test_build_image"),
Expand Down