diff --git a/readthedocs/doc_builder/environments.py b/readthedocs/doc_builder/environments.py index 8a40d389885..30821c157c1 100644 --- a/readthedocs/doc_builder/environments.py +++ b/readthedocs/doc_builder/environments.py @@ -1025,6 +1025,7 @@ def create_container(self): host_config=self.get_container_host_config(), detach=True, environment=self.environment, + user=settings.DOCKER_USER, ) client.start(container=self.container_id) except ConnectionError: diff --git a/readthedocs/settings/base.py b/readthedocs/settings/base.py index 3cf62523d59..8cde20a7c00 100644 --- a/readthedocs/settings/base.py +++ b/readthedocs/settings/base.py @@ -276,6 +276,15 @@ def USE_PROMOS(self): # noqa # Docker DOCKER_ENABLE = False + + # User used to create the container. + # In production we use the same user than the one defined by the + # ``USER docs`` instruction inside the Dockerfile. + # In development, we can use the "UID:GID" of the current user running the + # instance to avoid file permissions issues. + # https://docs.docker.com/engine/reference/run/#user + DOCKER_USER = 'docs:docs' + DOCKER_DEFAULT_IMAGE = 'readthedocs/build' DOCKER_DEFAULT_VERSION = 'latest' DOCKER_IMAGE = '{}:{}'.format(DOCKER_DEFAULT_IMAGE, DOCKER_DEFAULT_VERSION)