Visitar URL original
Allow different values for user_nsmode · Issue #3351 · docker/docker-py · GitHub
Skip to content

Allow different values for user_nsmode #3351

Open

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},
)

Activity

  1. bauen1 commented on Sep 16, 2025

    @bauen1

    I already implemented that in #3230

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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