DockerImage
- class aws_cdk.core.DockerImage(image, _image_hash=None)
Bases:
BundlingDockerImage
A Docker image.
- ExampleMetadata:
infused
Example:
entry = "/path/to/function" image = DockerImage.from_build(entry) lambda_.PythonFunction(self, "function", entry=entry, runtime=Runtime.PYTHON_3_8, bundling=lambda.BundlingOptions( build_args={"PIP_INDEX_URL": "https://your.index.url/simple/", "PIP_EXTRA_INDEX_URL": "https://your.extra-index.url/simple/"} ) )
- Parameters:
image (
str
)_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, security_opt=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.security_opt (
Optional
[str
]) – Security configuration when running the docker container. Default: - no security optionsuser (
Optional
[str
]) – The user to use when running the container. Default: - root or image defaultvolumes (
Optional
[Sequence
[Union
[DockerVolume
,Dict
[str
,Any
]]]]) – 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.
Static Methods
- classmethod from_asset(path, *, build_args=None, file=None, platform=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
platform (
Optional
[str
]) – Set platform if server is multi-platform capable. Requires Docker Engine API v1.38+. Example value:linux/amd64
Default: - no platform specified
- Deprecated:
use DockerImage.fromBuild()
- Stability:
deprecated
- Return type:
- classmethod from_build(path, *, build_args=None, file=None, platform=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
platform (
Optional
[str
]) – Set platform if server is multi-platform capable. Requires Docker Engine API v1.38+. Example value:linux/amd64
Default: - no platform specified
- Return type:
- classmethod from_registry(image)
Reference an image on DockerHub or another online registry.
- Parameters:
image (
str
) – the image name.- Return type: