Methods
(async) pullImage(options) → {Promise.<(void|Error)>}
- Description:
Pulls a Docker image using Dockerode.
- Source:
Example
pullImage({
docker: new Docker(),
logger: Logger("my-logger"),
imageName: "my-image",
}).then(() => {
console.log("Image pulled successfully");
}).catch(error => {
console.error("Error pulling image:", error);
});
Parameters:
Name | Type | Description | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object | The parameters for pulling the image. Properties
|
Returns:
A promise that resolves when the image is successfully pulled, or rejects with an error.
- Type
- Promise.<(void|Error)>
(async) runApplication(options) → {Promise.<(string|Error)>}
- Description:
Runs an application in a Docker container.
- Source:
Example
const scriptReadStream = fs.createReadStream("/path/to/your/script.tar.gz");
const execOptions = {
Cmd: ["node", "yourScript.js"],
AttachStdout: true,
AttachStderr: true
};
runApplication({
docker,
containerName: "myContainer",
scriptReadStream,
execOptions
}).then(console.log).catch(console.error);
Parameters:
Name | Type | Description | |||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object | The options for running the application. Properties
|
Returns:
A promise that resolves with the output of the script, or rejects with an error.
- Type
- Promise.<(string|Error)>
(async) startContainer(options) → {Promise.<(void|Error)>}
- Description:
Starts a Docker container using Dockerode.
- Source:
Example
startContainer({
docker: new Docker(),
logger: Logger("my-logger"),
imageName: "my-image",
containerOptions: {
name: "my-container",
ExposedPorts: {
"8080/tcp": {}
},
HostConfig: {
PortBindings: {
"8080/tcp": [
{
HostPort: "8080"
}
]
}
}
}
}).then(container => {
console.log("Container started:", container)
}).catch(error => {
console.error("Error starting container:", error);
});
Parameters:
Name | Type | Description | |||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object | The parameters for starting the container. Properties
|
Returns:
A promise that resolves when container is successfully started, or rejects with an error.
- Type
- Promise.<(void|Error)>
(async) stopContainer(options) → {Promise.<(void|Error)>}
- Description:
Stops a Docker container using Dockerode.
- Source:
Example
stopContainer({
docker: new Docker(),
logger: Logger("my-logger"),
containerName: "my-container",
}).then(() => {
console.log("Container stopped successfully")
}).catch(error => {
console.error("Error stopping container:", error);
});
Parameters:
Name | Type | Description | |||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object | The parameters for stopping the container. Default: {}. Properties
|
Returns:
A promise that resolves when the container is successfully stopped and removed, or rejects with an error if the container cannot be stopped or removed.
- Type
- Promise.<(void|Error)>