Skip to content
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

Use a non-root user in container for added security #193

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

gheorghiuradu
Copy link
Contributor

  • use a non-root user & group to run the app inside the container for improved security
  • use a high UID for compatibility with OpenShift

gheorghiuradu added 2 commits January 17, 2023 20:30
@hrj
Copy link
Contributor

hrj commented Jan 18, 2023

Hi @gheorghiuradu

I am not an expert in docker. Is this to avoid data/ directory having files owned by root, when running a container with docker?

Have you considered podman as an alternative? I believe it runs docker containers in daemon-less unprivileged mode. And podman and OpenShift are both from RedHat, so they should have good compatiblity.

@gheorghiuradu
Copy link
Contributor Author

Hi @hrj, thanks for asking

Indeed one of the reasons is to avoid having files and folders owned by root.
OpenShift requires containers to run as non-root users. I tried to run it using the RunAs parameter on their cloud platform, but it did not work as it did not have access to the /data folder.

Also, following the principle of least required prvilege, other tools like postgres or redis, use their own user inside their container image.

@hrj
Copy link
Contributor

hrj commented Jan 18, 2023

@gheorghiuradu Got it. Can you try using podman instead of docker. I have updated the README with instructions for podman as well. podman runs the container without privileges and without the need for a daemon. I tried it on my local machine and it worked fine.

If that works on openshift, I would prefer keeping the Dockerfile simple.

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

Successfully merging this pull request may close these issues.

2 participants