Skip to content

Unique container names are bad #17

Closed
@arnuschky

Description

@arnuschky

I know I can override container names, but I think the default implementation is bad.

Currently containers are named "pytest{}".format(os.getpid()). This leads to the following problems:

  • If test runs fail or are interrupted (ctrl-c), containers may stay around. Due to the unique names they start to accumulate. Same for images.
  • Docker-compose doesn't recognize that things belong to each other, and has conflicts. For example, if you use a static network subnet, then pytest-docker fails as different runs try to use the same network, but it's named separately.

This cost me days to debug (no docker wiz here).

Is there a specific reason why to use the pid-based naming? I would follow simply the behavior of docker-compose:

@pytest.fixture(scope='session')
def docker_compose_project_name(pytestconfig):
    """ Generate a project name using the projects root directory.

    Override this fixture in your tests if you need a particular project name.
    """
    return "{}pytest".format(os.path.basename(str(pytestconfig.rootdir)))

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions