大网数据广告活动
服务器运维问答

"docker-compose up" as root user or non-root user?

· 52CE 我爱测

After reading some articles I'm still not sure about what user I should use to run a docker container. Are there any security concerns when running a docker container as root user? Is it ok to run docker containers as root user O…

问题原文

原帖链接 · r00tusr · CC BY-SA 4.0

After reading some articles I'm still not sure about what user I should use to run a docker container. Are there any security concerns when running a docker container as root user? Is it ok to run docker containers as root user OR should I use my normal user, add him to the "docker" group and then run my containers OR should I create an additional user only for managing/creating docker containers?

root@myDockerHost:/opt/myDockerContainer# docker-compose up -d

VS

chris@myDockerHost:/opt/myDockerContainer# docker-compose up -d

VS

dockerusr@myDockerHost:/opt/myDockerContainer# docker-compose up -d

(I'm talking about the users on my docker host - not the user inside a container!)

社区高分解答

原帖链接 · Mike Diehn · CC BY-SA 4.0

r00tusr!

I vote for always running containers as regular users.

In a production system your containers won't be run as root. Even in non-production systems, the users who run your container might not be allowed to run programs as root.

So I like to make them work properly as an unprivileged user, even when it's difficult.

Also, there's the security consideration. The general rule professional sysadmins follow is never to run something as root unless it really, really must. Once a program is running as root, it has full control of the computer and can do anything to that computer that it is told to do. Whether that be the good works the author intended or nefarious works by a neer-do-well who cracks into the author's program through a vulnerability that author didn't think to close.

Since we've finally learned that we really, truly cannot predict which programs have flaws, we just don't take chances anymore.

Thanks! Mike

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2019-05-16)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。