DockerImage class
A Docker image built from a local context directory.
Use build to trigger the Docker daemon to build the image from path. The resulting image can then be referenced by DockerContainer using its tag or shortId.
Example:
await DockerImage.use(
DockerImage(path: './my-service', tag: 'my-service:test'),
(image) async {
final container = DockerContainer(image.tag!);
await DockerContainer.use(container, (c) async {
// run tests against c
});
},
);
Constructors
- DockerImage({required String path, String? tag, bool cleanUp = true, String? dockerfilePath, bool noCache = false, DockerClient? dockerClient})
- Creates a DockerImage from the given parameters.
Properties
- cleanUp → bool
-
Whether to remove the image after use completes.
final
- dockerfilePath → String?
-
Optional path to the Dockerfile relative to path.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
-
logs
→ List<
Map< String, dynamic> > -
The build log as a list of JSON log objects.
no setter
- noCache → bool
-
Whether to disable the Docker build cache (
--no-cache).final - path → String
-
The path to the Docker build context directory.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- shortId → String
-
Returns the first 12 characters of the image ID (the "short" form).
no setter
- tag → String?
-
Optional image tag applied to the built image (e.g.
'myapp:test').final
Methods
-
build(
) → Future< DockerImage> -
Builds the Docker image and returns
this. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
remove(
{bool force = true, bool noPrune = false}) → Future< void> - Removes the image from the local Docker image cache.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
use<
T> (DockerImage image, Future< T> fn(DockerImage)) → Future<T> -
Builds
image, runsfnwith it, and removes it afterwards.