question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Allow option to keep the containers alive

See original GitHub issue

It would be nice to keep the docker containers alive for speeding up the test runs. Now, in every test run containers are re-created and can’t keep them alive since this block

  def __del__(self):
        """
        Try to remove the container in all circumstances
        """
        if self._container is not None:
            try:
                self.stop()
            except:  # noqa: E722
                pass

removes containers when the instance variable is deleted (when the program terminates) and I cannot override it because this also runs without using with as block.

I don’t want my Mysql container to be recreated everytime. I am running tests very frequently and I am waiting couple seconds everytime. Pretty annoying.

I can make a small PR if that makes sense?

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:3
  • Comments:6

github_iconTop GitHub Comments

4reactions
tillahoffmanncommented, May 23, 2022

Sounds like there is sufficiently broad interest in this feature. We could add a remove: bool = True keyword argument to the constructor and keep the container alive if not remove. Note that a PR would now need to modify the atexit registration once #208 is merged.

2reactions
tillahoffmanncommented, Dec 22, 2020

@Can-Sahin, makes sense to want to keep the container alive to speed up tests. Having said that, I’m not sure how you’d be able to connect to the existing container after the reference to the instance variable has been discarded.

If you’re using pytest, you can use global fixtures to reuse the same container across all test runs within the same process. Reusing an existing container across different test runs/processes would require persisting information about the container across runs—container management should probably be outside the scope of this project.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Keep containers alive during daemon downtime
There are two ways to enable the live restore setting to keep containers alive when the daemon becomes unavailable. Only do one of...
Read more >
Enabling live restore on docker isn't keeping the containers ...
The live restore option only works to restore containers if the daemon options, such as bridge IP addresses and graph driver, did not...
Read more >
Keep containers alive during daemon downtime
Live restore supports keeping containers running across Docker daemon upgrades, though this is limited to patch releases and does not support minor or...
Read more >
How To Keep Docker Container Running For Debugging
To keep the container running, you need a foreground process added to the Docker Entrypoint. In the official Nginx image, the Nginx foreground ......
Read more >
podman-run
keep-groups is a special flag that tells Podman to keep the supplementary group access. Allows container to use the user's supplementary group access....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found