DockerImage¶
-
class
aws_cdk.core.
DockerImage
(image, _image_hash=None)¶ Bases:
aws_cdk.core.BundlingDockerImage
A Docker image.
- Parameters
image (
str
) – The Docker image._image_hash (
Optional
[str
]) –
Methods
-
cp
(image_path, output_path=None)¶ 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.- Parameters
image_path (
str
) – the path in the Docker image.output_path (
Optional
[str
]) – the destination path for the copy operation.
- Return type
str
- Returns
the destination path
-
run
(*, command=None, entrypoint=None, environment=None, user=None, volumes=None, working_directory=None)¶ Runs a Docker image.
- Parameters
command (
Optional
[Sequence
[str
]]) – The command to run in the container. Default: - run the command defined in the imageentrypoint (
Optional
[Sequence
[str
]]) – The entrypoint to run in the container. Default: - run the entrypoint defined in the imageenvironment (
Optional
[Mapping
[str
,str
]]) – The environment variables to pass to the container. Default: - no environment variables.user (
Optional
[str
]) – The user to use when running the container. Default: - root or image defaultvolumes (
Optional
[Sequence
[DockerVolume
]]) – Docker volumes to mount. Default: - no volumes are mountedworking_directory (
Optional
[str
]) – Working directory inside the container. Default: - image default
- Return type
None
-
to_json
()¶ Provides a stable representation of this image for JSON serialization.
- Return type
str
- Returns
The overridden image name if set or image hash name in that order
Attributes
-
image
¶ The Docker image.
- Return type
str
Static Methods
-
classmethod
from_asset
(path, *, build_args=None, file=None)¶ (deprecated) Reference an image that’s built directly from sources on disk.
- Parameters
path (
str
) – The path to the directory containing the Docker file.build_args (
Optional
[Mapping
[str
,str
]]) – Build args. Default: - no build argsfile (
Optional
[str
]) – Name of the Dockerfile, must relative to the docker build path. Default:Dockerfile
- Deprecated
use DockerImage.fromBuild()
- Stability
deprecated
- Return type
-
classmethod
from_build
(path, *, build_args=None, file=None)¶ Builds a Docker image.
- Parameters
path (
str
) – The path to the directory containing the Docker file.build_args (
Optional
[Mapping
[str
,str
]]) – Build args. Default: - no build argsfile (
Optional
[str
]) – Name of the Dockerfile, must relative to the docker build path. Default:Dockerfile
- Return type
-
classmethod
from_registry
(image)¶ Reference an image on DockerHub or another online registry.
- Parameters
image (
str
) – the image name.- Return type