Skip to content

DockerImage

A Docker image.

Initializers

import ros_cdk_core
ros_cdk_core.DockerImage(
  image: str,
  _imagehash: str = None
)
Name Type Description
image str No description.
_imagehash str No description.

imageRequired

  • Type: str

_imagehashOptional

  • Type: str

Methods

Name Description
cp Copies a file or directory out of the Docker image to the local filesystem.
run Runs a Docker image.
to_jso_n Provides a stable representation of this image for JSON serialization.

cp

def cp(
  image_path: str,
  output_path: str = None
) -> str

Copies a file or directory out of the Docker image to the local filesystem.

If outputPath is omitted the destination path is a temporary directory.

image_pathRequired

  • Type: str

the path in the Docker image.


output_pathOptional

  • Type: str

the destination path for the copy operation.


run

def run(
  command: typing.List[str] = None,
  entrypoint: typing.List[str] = None,
  environment: typing.Mapping[str] = None,
  network: str = None,
  platform: str = None,
  security_opt: str = None,
  user: str = None,
  volumes: typing.List[DockerVolume] = None,
  volumes_from: typing.List[str] = None,
  working_directory: str = None
) -> None

Runs a Docker image.

commandOptional

  • Type: typing.List[str]
  • Default: run the command defined in the image

The command to run in the container.


entrypointOptional

  • Type: typing.List[str]
  • Default: run the entrypoint defined in the image

The entrypoint to run in the container.


environmentOptional

  • Type: typing.Mapping[str]
  • Default: no environment variables.

The environment variables to pass to the container.


networkOptional

  • Type: str
  • Default: no networking options

Docker Networking options.


platformOptional

  • Type: str
  • Default: no platform specified

Set platform if server is multi-platform capable. Requires Docker Engine API v1.38+.

Example value: linux/amd64


security_optOptional

  • Type: str
  • Default: no security options

Security configuration when running the docker container.


userOptional

  • Type: str
  • Default: root or image default

The user to use when running the container.


volumesOptional

  • Type: typing.List[DockerVolume]
  • Default: no volumes are mounted

Docker volumes to mount.


volumes_fromOptional

  • Type: typing.List[str]
  • Default: no containers are specified to mount volumes from

Where to mount the specified volumes from.

https://docs.docker.com/engine/reference/commandline/run/#mount-volumes-from-container---volumes-from


working_directoryOptional

  • Type: str
  • Default: image default

Working directory inside the container.


to_jso_n

def to_jso_n() -> str

Provides a stable representation of this image for JSON serialization.

Static Functions

Name Description
from_build Builds a Docker image.
from_registry Reference an image on DockerHub or another online registry.

from_build

import ros_cdk_core
ros_cdk_core.DockerImage.from_build(
  path: str,
  build_args: typing.Mapping[str] = None,
  cache_disabled: bool = None,
  cache_from: typing.List[DockerCacheOption] = None,
  cache_to: DockerCacheOption = None,
  file: str = None,
  platform: str = None,
  target_stage: str = None
)

Builds a Docker image.

pathRequired

  • Type: str

The path to the directory containing the Docker file.


build_argsOptional

  • Type: typing.Mapping[str]
  • Default: no build args

Build args.


cache_disabledOptional

  • Type: bool
  • Default: cache is used

Disable the cache and pass --no-cache to the docker build command.


cache_fromOptional

Cache from options to pass to the docker build command.


cache_toOptional

Cache to options to pass to the docker build command.


fileOptional

  • Type: str
  • Default: Dockerfile

Name of the Dockerfile, must relative to the docker build path.


platformOptional

  • Type: str
  • Default: no platform specified

Set platform if server is multi-platform capable. Requires Docker Engine API v1.38+.

Example value: linux/amd64


target_stageOptional

  • Type: str
  • Default: Build all stages defined in the Dockerfile

Set build target for multi-stage container builds. Any stage defined afterwards will be ignored.

Example value: build-env


from_registry

import ros_cdk_core
ros_cdk_core.DockerImage.from_registry(
  image: str
)

Reference an image on DockerHub or another online registry.

imageRequired

  • Type: str

the image name.


Properties

Name Type Description
image str No description.

imageRequired

image: str
  • Type: str