Skip to content

Change default user in the Docker image from root to couchdb #71

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
mgangelov opened this issue Mar 5, 2018 · 5 comments
Closed

Change default user in the Docker image from root to couchdb #71

mgangelov opened this issue Mar 5, 2018 · 5 comments

Comments

@mgangelov
Copy link

I would like to change the defualt running user in the couchdb image from root to couchdb. What that means is basically when I do docker exec into the container I log in as couchdb rather than root. This is mainly aimed with security concerns in mind - I don't wont everybody who can log into the container to be root.

Expected Behavior

Be able to log in as user couchdb.

Current Behavior

I tried adding USER couchdb before the ENTRYPOINT in the Dockerfile, however it seems that root access is needed for docker-entrypoint.sh, so it seems I can't do that on the Dockerfile side.

Possible Solution

Steps to Reproduce (for bugs)

Context

Limit the root access for people logging into the container

Your Environment

Using the 2.1.1 image.

  • Version used: 2.1.1
  • Browser Name and version:
  • Operating System and version (desktop or mobile): Host system is Ubuntu 16.04
  • Link to your project:
@wohali
Copy link
Member

wohali commented Mar 5, 2018

I don't see how this is possible. Without root access inside of the container, we can't fix ownership of files in mounted volumes, which is an issue, since Docker mounts volumes as root. Unless Docker behaviour changes, we're blocked on this one.

Feel free to propose something in a PR.

@wohali wohali closed this as completed Mar 5, 2018
@mgangelov
Copy link
Author

mgangelov commented Mar 5, 2018

I actually just managed to do this by adding a USER couchdb tag after the ENTRYPOINT in the Dockerfile and also modifying exec gosu couchdb "$@" to exec "$@" in

exec gosu couchdb "$@"

This successfully modifies the ownership of mounted volume and also sets the default user in the container to couchdb.

Not tested yet if this solution will have problems when the couchdb container is actually used.

@wohali
Copy link
Member

wohali commented Mar 5, 2018

I don't see how this can work, since these lines explicitly need to change ownership of files that may be mounted via -v on the docker launch line, files that aren't necessarily owned by the couchdb user.

@bgehman
Copy link

bgehman commented Mar 27, 2019

@wohali There has been a considerable focus in the community to get containers to start and run as non-root -- for example: Openshift requires this: https://docs.openshift.com/container-platform/3.3/creating_images/guidelines.html

By default, OpenShift Container Platform runs containers using an arbitrarily assigned user ID. This provides additional security against processes escaping the container due to a container engine vulnerability and thereby achieving escalated permissions on the host node.

The couchdb image currently requires itself to start as root -- then it quickly de-escalates down to non-root (the internal couchdb user) for its internal processes. Per the OpenShift docs, they recommend that container files be owned by the root group, so the files are still read/writeable when they start the container with an arbitrarily assigned UID -- which avoids dealing with the file ownership problem you mentioned...

@wohali
Copy link
Member

wohali commented Mar 27, 2019 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants