mirror of
https://github.com/danbulant/docker-compose
synced 2026-06-24 01:11:48 +00:00
Add stopOne command
This commit is contained in:
parent
61d46416ef
commit
3cea146b6e
3 changed files with 15 additions and 0 deletions
|
|
@ -26,6 +26,7 @@ npm install --save-dev docker-compose
|
||||||
* `down(options)` - Stops containers and removes containers, networks, volumes, and images created by `up`
|
* `down(options)` - Stops containers and removes containers, networks, volumes, and images created by `up`
|
||||||
* `kill(options)` - Force stop service containers
|
* `kill(options)` - Force stop service containers
|
||||||
* `stop(options)` - Stop running containers without removing them
|
* `stop(options)` - Stop running containers without removing them
|
||||||
|
* `stopOne(service, options)` - Stops one container without removing it
|
||||||
* `rm(options)` - Remove stopped service containers - always uses the `-f` flag due to non interactive mode
|
* `rm(options)` - Remove stopped service containers - always uses the `-f` flag due to non interactive mode
|
||||||
* `exec(container, command, options)` - Exec `command` inside `container`, uses `-T` to properly handle stdin & stdout
|
* `exec(container, command, options)` - Exec `command` inside `container`, uses `-T` to properly handle stdin & stdout
|
||||||
* `logs(services, options)` - Show logs of service(s). Use `options.follow` `true|false` to turn on `--follow` flag.
|
* `logs(services, options)` - Show logs of service(s). Use `options.follow` `true|false` to turn on `--follow` flag.
|
||||||
|
|
|
||||||
|
|
@ -128,6 +128,10 @@ export const stop = function (options?: IDockerComposeOptions): Promise<IDockerC
|
||||||
return execCompose('stop', [], options);
|
return execCompose('stop', [], options);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const stopOne = function (service: string, options?: IDockerComposeOptions): Promise<IDockerComposeResult> {
|
||||||
|
return execCompose('stop', [ service ], options);
|
||||||
|
};
|
||||||
|
|
||||||
export const kill = function (options?: IDockerComposeOptions): Promise<IDockerComposeResult> {
|
export const kill = function (options?: IDockerComposeOptions): Promise<IDockerComposeResult> {
|
||||||
return execCompose('kill', [], options);
|
return execCompose('kill', [], options);
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -172,6 +172,16 @@ test('ensure container gets stopped', async (): Promise<void> => {
|
||||||
await compose.down({ cwd: path.join(__dirname), log: logOutput });
|
await compose.down({ cwd: path.join(__dirname), log: logOutput });
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('ensure only single container gets stopped', async (): Promise<void> => {
|
||||||
|
await compose.upAll({ cwd: path.join(__dirname), log: logOutput });
|
||||||
|
expect(await isContainerRunning('/compose_test_alpine')).toBeTruthy();
|
||||||
|
|
||||||
|
await compose.stopOne('alpine', { cwd: path.join(__dirname), log: logOutput });
|
||||||
|
expect(await isContainerRunning('/compose_test_alpine')).toBeFalsy();
|
||||||
|
expect(await isContainerRunning('/compose_test_nginx')).toBeTruthy();
|
||||||
|
await compose.down({ cwd: path.join(__dirname), log: logOutput });
|
||||||
|
});
|
||||||
|
|
||||||
test('ensure container gets killed', async (): Promise<void> => {
|
test('ensure container gets killed', async (): Promise<void> => {
|
||||||
await compose.upAll({ cwd: path.join(__dirname), log: logOutput });
|
await compose.upAll({ cwd: path.join(__dirname), log: logOutput });
|
||||||
expect(await isContainerRunning('/compose_test_nginx')).toBeTruthy();
|
expect(await isContainerRunning('/compose_test_nginx')).toBeTruthy();
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue