Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recognize when a container is already running #142

Open
leventov opened this issue Feb 19, 2020 · 2 comments
Open

Recognize when a container is already running #142

leventov opened this issue Feb 19, 2020 · 2 comments

Comments

@leventov
Copy link

Is your feature request related to a problem? Please describe.
If a container is already running, currently, Dockest timeouts in 30 seconds because it awaits for Docker start event:

export const resolveContainerId = async ({ runner, runner: { logger, dockerEventStream$ } }: { runner: Runner }) =>
race(
dockerEventStream$.pipe(
first(event => event.action === 'start'),
tap(({ id: containerId }) => {
logger.info(`${LOG_PREFIX} Success (${containerId})`, { success: true })
runner.containerId = containerId
}),
),
interval(1000).pipe(
tap(i => {
runner.logger.info(`Still waiting for start event... Timeout in ${DEFAULT_TIMEOUT - i}s`)

If Dockest allowed reusing existing containers, a developer could start a container once and make debugging loop shorter, because they don't need to wait for a container startup every time.

noRecreate option in composeOpts doesn't seem to work. It has nothing to do with the await of the start event in the code above.

@n1ru4l
Copy link
Collaborator

n1ru4l commented Feb 19, 2020

We can check whether a container is already running by using docker-compose ps -q <service-name>. However, we then could no longer rely on the container start events, as the event log is limited to the last 1000 occurring events. The approach would be a bit slower as we then need to poll again :/

@erikengervall
Copy link
Owner

I understand your use-case and I'd love for the local development experience to be smoother.

The focus of the library so far has been to create a means of running reliable integration tests in e.g. pipelines, rather than fast iterative local development.

I feel as if these concepts conflict with one another, which makes it hard to accommodate both without compromising reliability (which is still feel should be core).

I always welcome suggestions and/or PRs to amend this.

This could possible be an option in the future CLI (here's a first draft) which would alter behaviours, e.g. run docker-compose ps -q <service-name> rather than relying on docker events 🤷‍♂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants