docker / docker/docker-py

Allow different values for user_nsmode

Open
#3,351 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
7.2k
Forks
1.7k
Avg merge
13d 8h
Merged PRs (30d)
2

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The issue names create(...) and the low-level create_host_config/create_container path; start there to find where UsernsMode is restricted. Check the Podman value keep-id and confirm that the higher-level path preserves it in the resulting host configuration, with coverage for the newly accepted value.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker, python
Domain
api, backend
Issue type
Feature
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.