Skip to content

docker

docker documentation

toolroom._stubs.docker.Docker

Bases: Tool[_R]

Build

Bases: Tool[_R2]

__call__

__call__(
    path: str | PathLike[str],
    /,
    *args: str | PathLike[str],
    add_host: Value = ...,
    allow: Value = ...,
    annotation: Value = ...,
    attest: Value = ...,
    build_arg: Value = ...,
    build_context: Value = ...,
    builder: Value = ...,
    cache_from: Value = ...,
    cache_to: Value = ...,
    call: Value = ...,
    cgroup_parent: Value = ...,
    check: Flag = ...,
    compress: Flag = ...,
    cpu_period: Value = ...,
    cpu_quota: Value = ...,
    cpu_shares: Value = ...,
    cpuset_cpus: Value = ...,
    cpuset_mems: Value = ...,
    debug: Flag = ...,
    file: Value = ...,
    force_rm: Flag = ...,
    iidfile: Value = ...,
    isolation: Value = ...,
    label: Value = ...,
    load: Flag = ...,
    memory: Value = ...,
    memory_swap: Value = ...,
    metadata_file: Value = ...,
    network: Value = ...,
    no_cache: Flag = ...,
    no_cache_filter: Value = ...,
    output: Value = ...,
    platform: Value = ...,
    policy: Value = ...,
    progress: Value = ...,
    provenance: Value = ...,
    pull: Flag = ...,
    push: Flag = ...,
    quiet: Flag = ...,
    resource: Value = ...,
    rm: Flag = ...,
    sbom: Value = ...,
    secret: Value = ...,
    security_opt: Value = ...,
    shm_size: Value = ...,
    ssh: Value = ...,
    tag: Value = ...,
    target: Value = ...,
    ulimit: Value = ...,
    **flags: Any,
) -> _R2

Start a build

Parameters:

Name Type Description Default
add_host Value

Add a custom host-to-IP mapping (format: "host:ip").

...
allow Value

Allow extra privileged entitlement (e.g., "network.host", "security.insecure", "device", "buildx.local.delete"). May be repeated: a list emits the flag once per item.

...
annotation Value

Add annotation to the image. May be repeated: a list emits the flag once per item.

...
attest Value

Attestation parameters (format: "type=sbom,generator=image"). May be repeated: a list emits the flag once per item.

...
build_arg Value

Set build-time variables. May be repeated: a list emits the flag once per item.

...
build_context Value

Additional build contexts (e.g., name=path). May be repeated: a list emits the flag once per item.

...
builder Value

Override the configured builder instance. Defaults to default.

...
cache_from Value

External cache sources (e.g., "user/app:cache", "type=local,src=path/to/dir"). May be repeated: a list emits the flag once per item.

...
cache_to Value

Cache export destinations (e.g., "user/app:cache", "type=local,dest=path/to/dir"). May be repeated: a list emits the flag once per item.

...
call Value

Set method for evaluating build ("check", "outline", "targets"). Defaults to build.

...
cgroup_parent Value

Set the parent cgroup for the "RUN" instructions during build.

...
check Flag

Shorthand for "--call=check".

...
compress Flag

Compress the build context using gzip. Not available on Linux, Windows and macOS.

...
cpu_period Value

Limit the CPU CFS (Completely Fair Scheduler) period. Not available on Linux, Windows and macOS.

...
cpu_quota Value

Limit the CPU CFS (Completely Fair Scheduler) quota. Not available on Linux, Windows and macOS.

...
cpu_shares Value

CPU shares (relative weight). Not available on Linux, Windows and macOS.

...
cpuset_cpus Value

CPUs in which to allow execution (0-3, 0,1). Not available on Linux, Windows and macOS.

...
cpuset_mems Value

MEMs in which to allow execution (0-3, 0,1). Not available on Linux, Windows and macOS.

...
debug Flag

Enable debug logging.

...
file Value

Name of the Dockerfile. Defaults to PATH/Dockerfile.

...
force_rm Flag

Always remove intermediate containers. Not available on Linux, Windows and macOS.

...
iidfile Value

Write the image ID to a file.

...
isolation Value

Container isolation technology. Not available on Linux, Windows and macOS.

...
label Value

Set metadata for an image. May be repeated: a list emits the flag once per item.

...
load Flag

Shorthand for "--output=type=docker".

...
memory Value

Memory limit. Not available on Linux, Windows and macOS.

...
memory_swap Value

Swap limit equal to memory plus swap: -1 to enable unlimited swap. Not available on Linux, Windows and macOS.

...
metadata_file Value

Write build result metadata to a file.

...
network Value

Set the networking mode for the "RUN" instructions during build. Defaults to default.

...
no_cache Flag

Do not use cache when building the image.

...
no_cache_filter Value

Do not cache specified stages. May be repeated: a list emits the flag once per item.

...
output Value

Output destination (format: "type=local,dest=path"). May be repeated: a list emits the flag once per item.

...
platform Value

Set target platform for build. May be repeated: a list emits the flag once per item.

...
policy Value

Policy configuration (format: "filename=path[,filename=path][,reset=true|false][,disabled=true|false][,strict=true|false][,log-level=level]"). May be repeated: a list emits the flag once per item.

...
progress Value

Set type of progress output ("auto", "none", "plain", "quiet", "rawjson", "tty"). Defaults to auto.

...
provenance Value

Shorthand for "--attest=type=provenance".

...
pull Flag

Always attempt to pull all referenced images.

...
push Flag

Shorthand for "--output=type=registry,unpack=false".

...
quiet Flag

Suppress the build output and print image ID on success.

...
resource Value

Resource limits for build containers (format: "memory=2g", "cpu-quota=50000"). May be repeated: a list emits the flag once per item. Added in 29.6.0.

...
rm Flag

Remove intermediate containers after a successful build. Defaults to True. Not available on Linux, Windows and macOS.

...
sbom Value

Shorthand for "--attest=type=sbom".

...
secret Value

Secret to expose to the build (format: "id=mysecret[,src=/local/secret]"). May be repeated: a list emits the flag once per item.

...
security_opt Value

Security options. Not available on Linux, Windows and macOS.

...
shm_size Value

Shared memory size for build containers.

...
ssh Value

SSH agent socket or keys to expose to the build (format: "default|[=|[,]]"). May be repeated: a list emits the flag once per item.

...
tag Value

Image identifier (format: "[registry/]repository[:tag]"). May be repeated: a list emits the flag once per item.

...
target Value

Set the target build stage to build.

...
ulimit Value

Ulimit options. Defaults to [].

...

Compose

Bases: Tool[_R2]

Build

Bases: Tool[_R3]

__call__
__call__(
    *args: str | PathLike[str],
    build_arg: Value = ...,
    builder: Value = ...,
    check: Flag = ...,
    dry_run: Flag = ...,
    memory: Value = ...,
    no_cache: Flag = ...,
    print: Flag = ...,
    provenance: Value = ...,
    pull: Flag = ...,
    push: Flag = ...,
    quiet: Flag = ...,
    sbom: Value = ...,
    ssh: Value = ...,
    with_dependencies: Flag = ...,
    **flags: Any,
) -> _R3

Build or rebuild services

Parameters:

Name Type Description Default
build_arg Value

Set build-time variables for services. May be repeated: a list emits the flag once per item.

...
builder Value

Set builder to use.

...
check Flag

Check build configuration.

...
dry_run Flag

Execute command in dry run mode.

...
memory Value

Set memory limit for the build container.

...
no_cache Flag

Do not use cache when building the image.

...
print Flag

Print equivalent bake file.

...
provenance Value

Add a provenance attestation.

...
pull Flag

Always attempt to pull a newer version of the image.

...
push Flag

Push service images.

...
quiet Flag

Suppress the build output.

...
sbom Value

Add a SBOM attestation.

...
ssh Value

Set SSH authentications used when building service images.

...
with_dependencies Flag

Also build dependencies (transitively).

...

Down

Bases: Tool[_R3]

__call__
__call__(
    *args: str | PathLike[str],
    dry_run: Flag = ...,
    remove_orphans: Flag = ...,
    rmi: Value = ...,
    timeout: Value = ...,
    volumes: Flag = ...,
    **flags: Any,
) -> _R3

Stop and remove containers, networks

Parameters:

Name Type Description Default
dry_run Flag

Execute command in dry run mode.

...
remove_orphans Flag

Remove containers for services not defined in the Compose file.

...
rmi Value

Remove images used by services.

...
timeout Value

Specify a shutdown timeout in seconds.

...
volumes Flag

Remove named volumes declared in the "volumes" section of the Compose file and anonymous volumes attached to containers.

...

Exec

Bases: Tool[_R3]

__call__
__call__(
    service: str | PathLike[str],
    /,
    *args: str | PathLike[str],
    detach: Flag = ...,
    dry_run: Flag = ...,
    env: Value = ...,
    index: Value = ...,
    no_tty: Flag = ...,
    privileged: Flag = ...,
    user: Value = ...,
    workdir: Value = ...,
    **flags: Any,
) -> _R3

Execute a command in a running container

Parameters:

Name Type Description Default
detach Flag

Detached mode: Run command in the background.

...
dry_run Flag

Execute command in dry run mode.

...
env Value

Set environment variables. May be repeated: a list emits the flag once per item.

...
index Value

Index of the container if service has multiple replicas.

...
no_tty Flag

Disable pseudo-TTY allocation. Defaults to True.

...
privileged Flag

Give extended privileges to the process.

...
user Value

Run the command as this user.

...
workdir Value

Path to workdir directory for this command.

...

Logs

Bases: Tool[_R3]

__call__
__call__(
    *args: str | PathLike[str],
    dry_run: Flag = ...,
    follow: Flag = ...,
    index: Value = ...,
    no_color: Flag = ...,
    no_log_prefix: Flag = ...,
    since: Value = ...,
    tail: Value = ...,
    timestamps: Flag = ...,
    until: Value = ...,
    **flags: Any,
) -> _R3

View output from containers

Parameters:

Name Type Description Default
dry_run Flag

Execute command in dry run mode.

...
follow Flag

Follow log output.

...
index Value

index of the container if service has multiple replicas.

...
no_color Flag

Produce monochrome output.

...
no_log_prefix Flag

Don't print prefix in logs.

...
since Value

Show logs since timestamp (e.g.

...
tail Value

Number of lines to show from the end of the logs for each container. Defaults to all.

...
timestamps Flag

Show timestamps.

...
until Value

Show logs before a timestamp (e.g.

...

Ps

Bases: Tool[_R3]

__call__
__call__(
    *args: str | PathLike[str],
    all: Flag = ...,
    dry_run: Flag = ...,
    filter: Value = ...,
    format: Value = ...,
    no_trunc: Flag = ...,
    orphans: Flag = ...,
    quiet: Flag = ...,
    services: Flag = ...,
    status: Value = ...,
    **flags: Any,
) -> _R3

List containers

Parameters:

Name Type Description Default
all Flag

Show all stopped containers (including those created by the run command).

...
dry_run Flag

Execute command in dry run mode.

...
filter Value

Filter services by a property (supported filters: status).

...
format Value

Format output using a custom template: 'table': Print output in table format with column headers (default) 'table TEMPLATE': Print output in table format using the given Go template 'json': Print in JSON format 'TEMPLATE': Print output using the given Go template. Defaults to table.

...
no_trunc Flag

Don't truncate output.

...
orphans Flag

Include orphaned services (not declared by project). Defaults to True.

...
quiet Flag

Only display IDs.

...
services Flag

Display services.

...
status Value

Filter services by status. May be repeated: a list emits the flag once per item.

...

Run

Bases: Tool[_R3]

__call__
__call__(
    service: str | PathLike[str],
    /,
    *args: str | PathLike[str],
    build: Flag = ...,
    cap_add: Value = ...,
    cap_drop: Value = ...,
    detach: Flag = ...,
    dry_run: Flag = ...,
    entrypoint: Value = ...,
    env: Value = ...,
    env_from_file: Value = ...,
    interactive: Flag = ...,
    label: Value = ...,
    name: Value = ...,
    no_TTY: Flag = ...,
    no_deps: Flag = ...,
    no_tty: Flag = ...,
    publish: Value = ...,
    pull: Value = ...,
    quiet: Flag = ...,
    quiet_build: Flag = ...,
    quiet_pull: Flag = ...,
    remove_orphans: Flag = ...,
    rm: Flag = ...,
    service_ports: Flag = ...,
    use_aliases: Flag = ...,
    user: Value = ...,
    volume: Value = ...,
    workdir: Value = ...,
    **flags: Any,
) -> _R3

Run a one-off command on a service

Parameters:

Name Type Description Default
build Flag

Build image before starting container.

...
cap_add Value

Add Linux capabilities.

...
cap_drop Value

Drop Linux capabilities.

...
detach Flag

Run container in background and print container ID.

...
dry_run Flag

Execute command in dry run mode.

...
entrypoint Value

Override the entrypoint of the image.

...
env Value

Set environment variables. May be repeated: a list emits the flag once per item.

...
env_from_file Value

Set environment variables from file. May be repeated: a list emits the flag once per item.

...
interactive Flag

Keep STDIN open even if not attached. Defaults to True.

...
label Value

Add or override a label. May be repeated: a list emits the flag once per item.

...
name Value

Assign a name to the container.

...
no_TTY Flag

Disable pseudo-TTY allocation. Gone since 29.6.2.

...
no_deps Flag

Don't start linked services.

...
no_tty Flag

Disable pseudo-TTY allocation. Added in 29.6.2.

...
publish Value

Publish a container's port(s) to the host. May be repeated: a list emits the flag once per item.

...
pull Value

Pull image before running ("always"|"missing"|"never"). Defaults to policy.

...
quiet Flag

Don't print anything to STDOUT.

...
quiet_build Flag

Suppress progress output from the build process.

...
quiet_pull Flag

Pull without printing progress information.

...
remove_orphans Flag

Remove containers for services not defined in the Compose file.

...
rm Flag

Automatically remove the container when it exits.

...
service_ports Flag

Run command with all service's ports enabled and mapped to the host.

...
use_aliases Flag

Use the service's network useAliases in the network(s) the container connects to.

...
user Value

Run as specified username or uid.

...
volume Value

Bind mount a volume. May be repeated: a list emits the flag once per item.

...
workdir Value

Working directory inside the container.

...

Up

Bases: Tool[_R3]

__call__
__call__(
    *args: str | PathLike[str],
    abort_on_container_exit: Flag = ...,
    abort_on_container_failure: Flag = ...,
    always_recreate_deps: Flag = ...,
    attach: Value = ...,
    attach_dependencies: Flag = ...,
    build: Flag = ...,
    detach: Flag = ...,
    dry_run: Flag = ...,
    exit_code_from: Value = ...,
    force_recreate: Flag = ...,
    menu: Flag = ...,
    no_attach: Value = ...,
    no_color: Flag = ...,
    no_deps: Flag = ...,
    no_log_prefix: Flag = ...,
    no_recreate: Flag = ...,
    no_start: Flag = ...,
    pull: Value = ...,
    quiet_build: Flag = ...,
    quiet_pull: Flag = ...,
    remove_orphans: Flag = ...,
    renew_anon_volumes: Flag = ...,
    scale: Value = ...,
    timeout: Value = ...,
    timestamps: Flag = ...,
    wait: Flag = ...,
    wait_timeout: Value = ...,
    watch: Flag = ...,
    yes: Flag = ...,
    **flags: Any,
) -> _R3

Create and start containers

Parameters:

Name Type Description Default
abort_on_container_exit Flag

Stops all containers if any container was stopped.

...
abort_on_container_failure Flag

Stops all containers if any container exited with failure.

...
always_recreate_deps Flag

Recreate dependent containers.

...
attach Value

Restrict attaching to the specified services. May be repeated: a list emits the flag once per item.

...
attach_dependencies Flag

Automatically attach to log output of dependent services.

...
build Flag

Build images before starting containers. build=off emits --no-build.

...
detach Flag

Detached mode: Run containers in the background.

...
dry_run Flag

Execute command in dry run mode.

...
exit_code_from Value

Return the exit code of the selected service container.

...
force_recreate Flag

Recreate containers even if their configuration and image haven't changed.

...
menu Flag

Enable interactive shortcuts when running attached.

...
no_attach Value

Do not attach (stream logs) to the specified services. May be repeated: a list emits the flag once per item.

...
no_color Flag

Produce monochrome output.

...
no_deps Flag

Don't start linked services.

...
no_log_prefix Flag

Don't print prefix in logs.

...
no_recreate Flag

If containers already exist, don't recreate them.

...
no_start Flag

Don't start the services after creating them.

...
pull Value

Pull image before running ("always"|"missing"|"never"). Defaults to policy.

...
quiet_build Flag

Suppress the build output.

...
quiet_pull Flag

Pull without printing progress information.

...
remove_orphans Flag

Remove containers for services not defined in the Compose file.

...
renew_anon_volumes Flag

Recreate anonymous volumes instead of retrieving data from the previous containers.

...
scale Value

Scale SERVICE to NUM instances.

...
timeout Value

Use this timeout in seconds for container shutdown when attached or when containers are already running.

...
timestamps Flag

Show timestamps.

...
wait Flag

Wait for services to be running|healthy.

...
wait_timeout Value

Maximum duration in seconds to wait for the project to be running|healthy.

...
watch Flag

Watch source code and rebuild/refresh containers when files are updated.

...
yes Flag

Assume "yes" as answer to all prompts and run non-interactively.

...

flags

flags(**flags: Any) -> Self

Bind tool-level global options before the subcommand.

tools.docker.flags(host=...) puts a tool's own options ahead of the verb, where they belong.

Exec

Bases: Tool[_R2]

__call__

__call__(
    container: str | PathLike[str],
    /,
    *args: str | PathLike[str],
    detach: Flag = ...,
    detach_keys: Value = ...,
    env: Value = ...,
    env_file: Value = ...,
    interactive: Flag = ...,
    privileged: Flag = ...,
    tty: Flag = ...,
    user: Value = ...,
    workdir: Value = ...,
    **flags: Any,
) -> _R2

Execute a command in a running container

Parameters:

Name Type Description Default
detach Flag

Detached mode: run command in the background.

...
detach_keys Value

Override the key sequence for detaching a container.

...
env Value

Set environment variables.

...
env_file Value

Read in a file of environment variables.

...
interactive Flag

Keep STDIN open even if not attached.

...
privileged Flag

Give extended privileges to the command.

...
tty Flag

Allocate a pseudo-TTY.

...
user Value

Username or UID (format: "[:]").

...
workdir Value

Working directory inside the container.

...

Images

Bases: Tool[_R2]

__call__

__call__(
    *args: str | PathLike[str],
    all: Flag = ...,
    digests: Flag = ...,
    filter: Value = ...,
    format: Value = ...,
    no_trunc: Flag = ...,
    quiet: Flag = ...,
    tree: Flag = ...,
    **flags: Any,
) -> _R2

List images

Parameters:

Name Type Description Default
all Flag

Show all images.

...
digests Flag

Show digests.

...
filter Value

Filter output based on conditions provided.

...
format Value

Format output using a custom template: 'table': Print output in table format with column headers (default) 'table TEMPLATE': Print output in table format using the given Go template 'json': Print in JSON format 'TEMPLATE': Print output using the given Go template.

...
no_trunc Flag

Don't truncate output.

...
quiet Flag

Only show image IDs.

...
tree Flag

List multi-platform images as a tree (EXPERIMENTAL).

...

Logs

Bases: Tool[_R2]

__call__

__call__(
    container: str | PathLike[str],
    /,
    *args: str | PathLike[str],
    details: Flag = ...,
    follow: Flag = ...,
    since: Value = ...,
    tail: Value = ...,
    timestamps: Flag = ...,
    until: Value = ...,
    **flags: Any,
) -> _R2

Fetch the logs of a container

Parameters:

Name Type Description Default
details Flag

Show extra details provided to logs.

...
follow Flag

Follow log output.

...
since Value

Show logs since timestamp (e.g.

...
tail Value

Number of lines to show from the end of the logs. Defaults to all.

...
timestamps Flag

Show timestamps.

...
until Value

Show logs before a timestamp (e.g.

...

Ps

Bases: Tool[_R2]

__call__

__call__(
    *,
    all: Flag = ...,
    filter: Value = ...,
    format: Value = ...,
    last: Value = ...,
    latest: Flag = ...,
    no_trunc: Flag = ...,
    quiet: Flag = ...,
    size: Flag = ...,
    **flags: Any,
) -> _R2

List containers

Parameters:

Name Type Description Default
all Flag

Show all containers.

...
filter Value

Filter output based on conditions provided.

...
format Value

Format output using a custom template: 'table': Print output in table format with column headers (default) 'table TEMPLATE': Print output in table format using the given Go template 'json': Print in JSON format 'TEMPLATE': Print output using the given Go template.

...
last Value

Show n last created containers (includes all states). Defaults to -1.

...
latest Flag

Show the latest created container (includes all states).

...
no_trunc Flag

Don't truncate output.

...
quiet Flag

Only display container IDs.

...
size Flag

Display total file sizes.

...

Pull

Bases: Tool[_R2]

__call__

__call__(
    name: str | PathLike[str],
    /,
    *args: str | PathLike[str],
    all_tags: Flag = ...,
    platform: Value = ...,
    quiet: Flag = ...,
    **flags: Any,
) -> _R2

Download an image from a registry

Parameters:

Name Type Description Default
all_tags Flag

Download all tagged images in the repository.

...
platform Value

Set platform if server is multi-platform capable.

...
quiet Flag

Suppress verbose output.

...

Push

Bases: Tool[_R2]

__call__

__call__(
    name: str | PathLike[str],
    /,
    *args: str | PathLike[str],
    all_tags: Flag = ...,
    platform: Value = ...,
    quiet: Flag = ...,
    **flags: Any,
) -> _R2

Upload an image to a registry

Parameters:

Name Type Description Default
all_tags Flag

Push all tags of an image to the repository.

...
platform Value

Push a platform-specific manifest as a single-platform image to the registry.

...
quiet Flag

Suppress verbose output.

...

Run

Bases: Tool[_R2]

__call__

__call__(
    image: str | PathLike[str],
    /,
    *args: str | PathLike[str],
    add_host: Value = ...,
    annotation: Value = ...,
    attach: Value = ...,
    blkio_weight: Value = ...,
    blkio_weight_device: Value = ...,
    cap_add: Value = ...,
    cap_drop: Value = ...,
    cgroup_parent: Value = ...,
    cgroupns: Value = ...,
    cidfile: Value = ...,
    cpu_count: Value = ...,
    cpu_percent: Value = ...,
    cpu_period: Value = ...,
    cpu_quota: Value = ...,
    cpu_rt_period: Value = ...,
    cpu_rt_runtime: Value = ...,
    cpu_shares: Value = ...,
    cpus: Value = ...,
    cpuset_cpus: Value = ...,
    cpuset_mems: Value = ...,
    detach: Flag = ...,
    detach_keys: Value = ...,
    device: Value = ...,
    device_cgroup_rule: Value = ...,
    device_read_bps: Value = ...,
    device_read_iops: Value = ...,
    device_write_bps: Value = ...,
    device_write_iops: Value = ...,
    dns: Value = ...,
    dns_option: Value = ...,
    dns_search: Value = ...,
    domainname: Value = ...,
    entrypoint: Value = ...,
    env: Value = ...,
    env_file: Value = ...,
    expose: Value = ...,
    gpus: Value = ...,
    group_add: Value = ...,
    health_cmd: Value = ...,
    health_interval: Value = ...,
    health_retries: Value = ...,
    health_start_interval: Value = ...,
    health_start_period: Value = ...,
    health_timeout: Value = ...,
    hostname: Value = ...,
    init: Flag = ...,
    interactive: Flag = ...,
    io_maxbandwidth: Value = ...,
    io_maxiops: Value = ...,
    ip: Value = ...,
    ip6: Value = ...,
    ipc: Value = ...,
    isolation: Value = ...,
    label: Value = ...,
    label_file: Value = ...,
    link: Value = ...,
    link_local_ip: Value = ...,
    log_driver: Value = ...,
    log_opt: Value = ...,
    mac_address: Value = ...,
    memory: Value = ...,
    memory_reservation: Value = ...,
    memory_swap: Value = ...,
    memory_swappiness: Value = ...,
    mount: Value = ...,
    name: Value = ...,
    network: Value = ...,
    network_alias: Value = ...,
    no_healthcheck: Flag = ...,
    oom_kill_disable: Flag = ...,
    oom_score_adj: Value = ...,
    pid: Value = ...,
    pids_limit: Value = ...,
    platform: Value = ...,
    privileged: Flag = ...,
    publish: Value = ...,
    publish_all: Flag = ...,
    pull: Value = ...,
    quiet: Flag = ...,
    read_only: Flag = ...,
    restart: Value = ...,
    rm: Flag = ...,
    runtime: Value = ...,
    security_opt: Value = ...,
    shm_size: Value = ...,
    sig_proxy: Flag = ...,
    stop_signal: Value = ...,
    stop_timeout: Value = ...,
    storage_opt: Value = ...,
    sysctl: Value = ...,
    tmpfs: Value = ...,
    tty: Flag = ...,
    ulimit: Value = ...,
    use_api_socket: Flag = ...,
    user: Value = ...,
    userns: Value = ...,
    uts: Value = ...,
    volume: Value = ...,
    volume_driver: Value = ...,
    volumes_from: Value = ...,
    workdir: Value = ...,
    **flags: Any,
) -> _R2

Create and run a new container from an image

Parameters:

Name Type Description Default
add_host Value

Add a custom host-to-IP mapping (host:ip).

...
annotation Value

Add an annotation to the container (passed through to the OCI runtime). Defaults to map[].

...
attach Value

Attach to STDIN, STDOUT or STDERR.

...
blkio_weight Value

Block IO (relative weight), between 10 and 1000, or 0 to disable. Defaults to 0.

...
blkio_weight_device Value

Block IO weight (relative device weight). Defaults to [].

...
cap_add Value

Add Linux capabilities.

...
cap_drop Value

Drop Linux capabilities.

...
cgroup_parent Value

Optional parent cgroup for the container.

...
cgroupns Value

Cgroup namespace to use (host|private) 'host': Run the container in the Docker host's cgroup namespace 'private': Run the container in its own private cgroup namespace '': Use the cgroup namespace as configured by the default-cgroupns-mode option on the daemon (default).

...
cidfile Value

Write the container ID to the file.

...
cpu_count Value

CPU count (Windows only). Not available on Linux.

...
cpu_percent Value

CPU percent (Windows only). Not available on Linux.

...
cpu_period Value

Limit CPU CFS (Completely Fair Scheduler) period.

...
cpu_quota Value

Limit CPU CFS (Completely Fair Scheduler) quota.

...
cpu_rt_period Value

Limit CPU real-time period in microseconds.

...
cpu_rt_runtime Value

Limit CPU real-time runtime in microseconds.

...
cpu_shares Value

CPU shares (relative weight).

...
cpus Value

Number of CPUs.

...
cpuset_cpus Value

CPUs in which to allow execution (0-3, 0,1).

...
cpuset_mems Value

MEMs in which to allow execution (0-3, 0,1).

...
detach Flag

Run container in background and print container ID.

...
detach_keys Value

Override the key sequence for detaching a container.

...
device Value

Add a host device to the container.

...
device_cgroup_rule Value

Add a rule to the cgroup allowed devices list.

...
device_read_bps Value

Limit read rate (bytes per second) from a device. Defaults to [].

...
device_read_iops Value

Limit read rate (IO per second) from a device. Defaults to [].

...
device_write_bps Value

Limit write rate (bytes per second) to a device. Defaults to [].

...
device_write_iops Value

Limit write rate (IO per second) to a device. Defaults to [].

...
dns Value

Set custom DNS servers.

...
dns_option Value

Set DNS options.

...
dns_search Value

Set custom DNS search domains.

...
domainname Value

Container NIS domain name.

...
entrypoint Value

Overwrite the default ENTRYPOINT of the image.

...
env Value

Set environment variables.

...
env_file Value

Read in a file of environment variables.

...
expose Value

Expose a port or a range of ports.

...
gpus Value

GPU devices to add to the container ('all' to pass all GPUs).

...
group_add Value

Add additional groups to join.

...
health_cmd Value

Command to run to check health.

...
health_interval Value

Time between running the check (ms|s|m|h). Defaults to 0s.

...
health_retries Value

Consecutive failures needed to report unhealthy.

...
health_start_interval Value

Time between running the check during the start period (ms|s|m|h). Defaults to 0s.

...
health_start_period Value

Start period for the container to initialize before starting health-retries countdown (ms|s|m|h). Defaults to 0s.

...
health_timeout Value

Maximum time to allow one check to run (ms|s|m|h). Defaults to 0s.

...
hostname Value

Container host name.

...
init Flag

Run an init inside the container that forwards signals and reaps processes.

...
interactive Flag

Keep STDIN open even if not attached.

...
io_maxbandwidth Value

Maximum IO bandwidth limit for the system drive (Windows only). Not available on Linux.

...
io_maxiops Value

Maximum IOps limit for the system drive (Windows only). Not available on Linux.

...
ip Value

IPv4 address (e.g., 172.30.100.104).

...
ip6 Value

IPv6 address (e.g., 2001:db8::33).

...
ipc Value

IPC mode to use.

...
isolation Value

Container isolation technology.

...
label Value

Set meta data on a container.

...
label_file Value

Read in a line delimited file of labels.

...
link Value

Add link to another container.

...
link_local_ip Value

Container IPv4/IPv6 link-local addresses.

...
log_driver Value

Logging driver for the container.

...
log_opt Value

Log driver options.

...
mac_address Value

Container MAC address (e.g., 92:d0:c6:0a:29:33).

...
memory Value

Memory limit.

...
memory_reservation Value

Memory soft limit.

...
memory_swap Value

Swap limit equal to memory plus swap: '-1' to enable unlimited swap.

...
memory_swappiness Value

Tune container memory swappiness (0 to 100). Defaults to -1.

...
mount Value

Attach a filesystem mount to the container.

...
name Value

Assign a name to the container.

...
network Value

Connect a container to a network.

...
network_alias Value

Add network-scoped alias for the container.

...
no_healthcheck Flag

Disable any container-specified HEALTHCHECK.

...
oom_kill_disable Flag

Disable OOM Killer.

...
oom_score_adj Value

Tune host's OOM preferences (-1000 to 1000).

...
pid Value

PID namespace to use.

...
pids_limit Value

Tune container pids limit (set -1 for unlimited).

...
platform Value

Set platform if server is multi-platform capable.

...
privileged Flag

Give extended privileges to this container.

...
publish Value

Publish a container's port(s) to the host.

...
publish_all Flag

Publish all exposed ports to random ports.

...
pull Value

Pull image before running ("always", "missing", "never"). Defaults to missing.

...
quiet Flag

Suppress the pull output.

...
read_only Flag

Mount the container's root filesystem as read only.

...
restart Value

Restart policy to apply when a container exits. Defaults to no.

...
rm Flag

Automatically remove the container and its associated anonymous volumes when it exits.

...
runtime Value

Runtime to use for this container.

...
security_opt Value

Security Options.

...
shm_size Value

Size of /dev/shm.

...
sig_proxy Flag

Proxy received signals to the process. Defaults to True.

...
stop_signal Value

Signal to stop the container.

...
stop_timeout Value

Timeout (in seconds) to stop a container.

...
storage_opt Value

Storage driver options for the container.

...
sysctl Value

Sysctl options. Defaults to map[].

...
tmpfs Value

Mount a tmpfs directory.

...
tty Flag

Allocate a pseudo-TTY.

...
ulimit Value

Ulimit options. Defaults to [].

...
use_api_socket Flag

Bind mount Docker API socket and required auth.

...
user Value

Username or UID (format: [:]).

...
userns Value

User namespace to use.

...
uts Value

UTS namespace to use.

...
volume Value

Bind mount a volume.

...
volume_driver Value

Optional volume driver for the container.

...
volumes_from Value

Mount volumes from the specified container(s).

...
workdir Value

Working directory inside the container.

...

__call__

__call__(
    *args: str | PathLike[str],
    config: Value = ...,
    context: Value = ...,
    debug: Flag = ...,
    host: Value = ...,
    log_level: Value = ...,
    tls: Flag = ...,
    tlscacert: Value = ...,
    tlscert: Value = ...,
    tlskey: Value = ...,
    tlsverify: Flag = ...,
    **flags: Any,
) -> _R

A self-sufficient runtime for containers

Parameters:

Name Type Description Default
config Value

Location of client config files. Defaults to ~\.docker.

...
context Value

Name of the context to use to connect to the daemon (overrides DOCKER_HOST env var and default context set with "docker context use").

...
debug Flag

Enable debug mode.

...
host Value

Daemon socket to connect to.

...
log_level Value

Set the logging level ("debug", "info", "warn", "error", "fatal"). Defaults to info.

...
tls Flag

Use TLS; implied by --tlsverify.

...
tlscacert Value

Trust certs signed only by this CA. Defaults to ~\.docker\ca.pem.

...
tlscert Value

Path to TLS certificate file. Defaults to ~\.docker\cert.pem.

...
tlskey Value

Path to TLS key file. Defaults to ~\.docker\key.pem.

...
tlsverify Flag

Use TLS and verify the remote.

...

flags

flags(
    *,
    config: Value = ...,
    context: Value = ...,
    debug: Flag = ...,
    host: Value = ...,
    log_level: Value = ...,
    tls: Flag = ...,
    tlscacert: Value = ...,
    tlscert: Value = ...,
    tlskey: Value = ...,
    tlsverify: Flag = ...,
    **flags: Any,
) -> Self

Bind tool-level global options before the subcommand.

tools.docker.flags(host=...) puts a tool's own options ahead of the verb, where they belong.