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

Best practices for docker users on a shared machine

· 52CE 我爱测

We would like to use docker on the servers of our university. From reading https://docs.docker.com/install/linux/linux-postinstall/#manage-docker-as-a-non-root-user I understand that it is recommended to create a Unix group docke…

问题原文

原帖链接 · Mathias Müller · CC BY-SA 4.0

We would like to use docker on the servers of our university. From reading

https://docs.docker.com/install/linux/linux-postinstall/#manage-docker-as-a-non-root-user

I understand that it is recommended to create a Unix group docker and add users to this group. In my research group we share one server machine, so naturally I would add several people to the docker group.

But does this also mean every member of the docker group can, among other things, start and stop any container, even if the containers are not their own? To me this seems to be impractical.

More generally, my question is:

What are best practices for teams to use docker on a shared machine?

已采纳解答

原帖链接 · linux-fan · CC BY-SA 4.0

TL;DR: docker group membership = root rights

The docker group

It is true that is an often read advice to add users which should be able to use docker to the docker group. However, as users are root inside containers and can mount any path on the system by using -v (even the paths they do not normally have access to), this is effectively giving all users root rights.

It is thus only to be considered a "minor" concern that the users can mess with other users' containers. They can actually do anything with the system if they are members of the docker group.

Docker on a shared machine

If it really needs to be the original Docker, consider two options:

1. The stable solution: Docker in VM

What I am doing all the time is running Docker inside virtual machines. You add one virtual machine per user to the shared machine and then allow the users to run containers within that machine. Of course, this only works if you can tolerate the resource overhead (and with many users of which only few are logged in at the time, it might be necessary to develop some scheme to start and stop VMs automatically).

2. The experimental solution: Rootless Docker

I do not know the current state of the project but there is work on making Docker available without root s.t. a user can just run their own Docker (without needing any group memberships). See https://engineering.docker.com/2019/02/experimenting-with-rootless-docker/

Another solution: Alternative to Docker.

In case it need not be Docker but any container environment, consider the alternatives. I have read that podman offers a very similar interface without the need for running it as root.

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

资料来源与适用范围

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

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

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