Skip to content

Docker compose start with selected service #315

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

Closed
MCatherine1994 opened this issue Mar 6, 2023 · 2 comments · Fixed by #337
Closed

Docker compose start with selected service #315

MCatherine1994 opened this issue Mar 6, 2023 · 2 comments · Fixed by #337
Labels
✅ close on merge Issue that will be closed by an open pull request 🚀 enhancement 📦 package: compose

Comments

@MCatherine1994
Copy link

MCatherine1994 commented Mar 6, 2023

Hello there, I wonder if we could run the docker container based on a docker compose file, but only run the selected service inside it? like doing this command docker-compose up [service_name], is there any method can support that?

Currently we're using:

import testcontainers.compose
compose = testcontainers.compose.DockerCompose(COMPOSE_PATH)
compose.start()

But it will start all the services, but we just want to start selected services.

Thanks!!

@tillahoffmann
Copy link
Collaborator

tillahoffmann commented Apr 11, 2023

Yes, that should be possible in principle by modifying the start function. Contributions welcome!

def start(self) -> None:
"""
Starts the docker compose environment.
"""
if self.pull:
pull_cmd = self.docker_compose_command() + ['pull']
self._call_command(cmd=pull_cmd)
up_cmd = self.docker_compose_command() + ['up', '-d']
if self.build:
up_cmd.append('--build')
self._call_command(cmd=up_cmd)

@balint-backmaker
Copy link
Contributor

balint-backmaker commented Apr 18, 2023

@tillahoffmann I'd be interested in picking this up, just the matter of fitting it into my usual duties at the company I work for.

Having said that, a simple "services" component should be a no-brainer! Expect a PR soon! :)

EDIT:
I guess in return I'm just curious about your review/release schedule! I couldn't find the obvious doc in the repo (like CONTRIBUTING.md or alike)
CODEOWNERS doesn't seem to indicate an owner of the /compose iether so I'd be interested in volunteering, dependent on how your contribution guide looks like ofc. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
✅ close on merge Issue that will be closed by an open pull request 🚀 enhancement 📦 package: compose
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants