Skip to content

Allow different values for user_nsmode #3351

@pferreir

Description

@pferreir

create(...) currently allows only host as UsernsMode. This seems to make sense as docker only allows this as an option. However, podman supports a few others. I assume this package should be able to interact with other docker-compatible APIs, and in that case it would make sense that we can set this parameter differently.
Right now, the only workaround I've found was to use the low level API as such:

host_config = api_client.create_host_config(
    binds={
        socket_dir: {'bind': '/var/run/postgresql', 'mode': 'rw'},
        data_dir: {'bind': '/var/lib/postgresql/data', 'mode': 'rw'},
    }
)

# kind of hacky, right?
host_config['UsernsMode'] = 'keep-id'

container_config = api_client.create_container(
    image=POSTGRES_IMAGE,
    name=CONTAINER_NAME,
    user=f'{os.getuid()}:{os.getgid()}',
    host_config=host_config,
    environment={'POSTGRES_USER': 'postgres', 'POSTGRES_PASSWORD': 'postgres', 'POSTGRES_DB': db_name},
)

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