pub struct PushCommand {
pub executor: CommandExecutor,
/* private fields */
}
Expand description
Docker Push Command Builder
Implements the docker push
command for uploading images to registries.
§Docker Push Overview
The push command uploads images from the local Docker daemon to Docker registries (like Docker Hub, AWS ECR, or private registries). It supports:
- Single image push by name and tag
- All tags push for a repository
- Platform-specific manifest pushing
- Quiet mode for minimal output
- Content trust signing control
§Image Naming
Images can be specified in several formats:
image:tag
- Image with specific tagregistry/image:tag
- Specific registryregistry:port/image:tag
- Custom registry portnamespace/image:tag
- Namespaced image (e.g., Docker Hub organizations)
§Registry Authentication
Push operations typically require authentication. Use docker login
first
or configure registry credentials through Docker configuration files.
§Examples
use docker_wrapper::PushCommand;
use docker_wrapper::DockerCommand;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Push to Docker Hub
let output = PushCommand::new("username/myapp:v1.0")
.execute()
.await?;
println!("Push success: {}", output.success);
Ok(())
}
Fields§
§executor: CommandExecutor
Command executor for handling raw arguments and execution
Implementations§
Source§impl PushCommand
impl PushCommand
Push all tags of an image to the repository
When enabled, pushes all available tags for the specified image repository. The image name should not include a specific tag when using this option.
§Examples
use docker_wrapper::PushCommand;
let push_cmd = PushCommand::new("myregistry.com/myapp")
.all_tags();
Sourcepub fn disable_content_trust(self) -> Self
pub fn disable_content_trust(self) -> Self
Skip image signing (disable content trust)
By default, Docker may sign images when content trust is enabled. This option disables that signing process.
§Examples
use docker_wrapper::PushCommand;
let push_cmd = PushCommand::new("myapp:latest")
.disable_content_trust();
Sourcepub fn platform<S: Into<String>>(self, platform: S) -> Self
pub fn platform<S: Into<String>>(self, platform: S) -> Self
Push a platform-specific manifest as a single-platform image
Pushes only the specified platform variant of a multi-platform image. The image index won’t be pushed, meaning other manifests including attestations won’t be preserved.
Platform format: os[/arch[/variant]]
Common platform values:
linux/amd64
- 64-bit Intel/AMD Linuxlinux/arm64
- 64-bit ARM Linuxlinux/arm/v7
- 32-bit ARM Linuxwindows/amd64
- 64-bit Windows
§Examples
use docker_wrapper::PushCommand;
let push_cmd = PushCommand::new("myapp:latest")
.platform("linux/amd64");
Sourcepub fn quiet(self) -> Self
pub fn quiet(self) -> Self
Suppress verbose output
Reduces the amount of output during the push operation.
§Examples
use docker_wrapper::PushCommand;
let push_cmd = PushCommand::new("myapp:latest")
.quiet();
Sourcepub fn get_image(&self) -> &str
pub fn get_image(&self) -> &str
Get the image name
§Examples
use docker_wrapper::PushCommand;
let push_cmd = PushCommand::new("myapp:latest");
assert_eq!(push_cmd.get_image(), "myapp:latest");
Check if all tags mode is enabled
§Examples
use docker_wrapper::PushCommand;
let push_cmd = PushCommand::new("myapp").all_tags();
assert!(push_cmd.is_all_tags());
Sourcepub fn is_quiet(&self) -> bool
pub fn is_quiet(&self) -> bool
Check if quiet mode is enabled
§Examples
use docker_wrapper::PushCommand;
let push_cmd = PushCommand::new("myapp").quiet();
assert!(push_cmd.is_quiet());
Sourcepub fn get_platform(&self) -> Option<&str>
pub fn get_platform(&self) -> Option<&str>
Get the platform if set
§Examples
use docker_wrapper::PushCommand;
let push_cmd = PushCommand::new("myapp").platform("linux/arm64");
assert_eq!(push_cmd.get_platform(), Some("linux/arm64"));
Sourcepub fn is_content_trust_disabled(&self) -> bool
pub fn is_content_trust_disabled(&self) -> bool
Check if content trust is disabled
§Examples
use docker_wrapper::PushCommand;
let push_cmd = PushCommand::new("myapp").disable_content_trust();
assert!(push_cmd.is_content_trust_disabled());
Sourcepub fn get_executor(&self) -> &CommandExecutor
pub fn get_executor(&self) -> &CommandExecutor
Get a reference to the command executor
Sourcepub fn get_executor_mut(&mut self) -> &mut CommandExecutor
pub fn get_executor_mut(&mut self) -> &mut CommandExecutor
Get a mutable reference to the command executor
Trait Implementations§
Source§impl Clone for PushCommand
impl Clone for PushCommand
Source§fn clone(&self) -> PushCommand
fn clone(&self) -> PushCommand
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more