song4's recent timeline updates
song4

song4

我想到了一个绝妙的签名,可惜这里太小,写不下。
V2EX member #57436, joined on 2014-03-05 13:05:50 +08:00
物理系出身,却干上了程序员的行当。

染指C++、Node.js、Python和Java。

喜好数学、物理、逻辑和哲学。

对于有同样爱好的童鞋,我只有一句话:请联系我。
song4's recent replies
支持一下,想来新加坡的朋友们可以考虑一下。这枚 HR 超赞的。
先回答第一个问题:

> 如果 docker 中的用户名交 dockeruser 宿主机没有这个用户,他是怎么映射的呢?按照 uid 吗?

是的,按照 uid 来映射。默认从 uid=0 开始映射,宿主机的 uid=0,1,2,... 映射为容器的 uid=0,1,2,...。你可以通过 `--userns-remap` 选项来改变这个行为,比如说可以指定宿主机的 uid=1000,1001,1002,... 映射为容器的 uid=0,1,2,...。

第二个问题:

> 所以在容器内就是 root 权限了,怎么避免呢?

事实确实是这样的,你可以参考 LWN 的这篇文章:[User namespaces + overlayfs = root privileges]( https://lwn.net/Articles/671641/)。这一点其实在 Docker 官方给出的 [Docker daemon attack surface]( https://docs.docker.com/engine/security/security/) 中也已经指出来了:

> Docker allows you to share a directory between the Docker host and a guest container; and it allows you to do so without limiting the access rights of the container. This means that you can start a container where the /host directory is the / directory on your host; and the container can alter your host filesystem without any restriction. This is similar to how virtualization systems allow filesystem resource sharing. Nothing prevents you from sharing your root filesystem (or even your root block device) with a virtual machine.

那么,怎么避免呢?一种方案是,可以在运行容器的时候通过 `--user` 选项指定非 root 用户名和组。另外,挂载 volumes 的时候遵循 Principle of Least Privilege 是一个好习惯:尽量避免挂载系统重要的目录或文件,如果实在需要,不妨使用只读挂载。
@monsterxx03 是对的,做 Capacity Planning 的话,还需要知道应用的工作负载特征。
@abmin521 是的
我是 DevOps 工程师
@tyrealgray 这个应该好协调的吧,不清楚您当时的具体情况 😂
@mygoare 我们业务中用到的是 React,如果你学习能力足够强,欢迎投递简历!
@jishu541464750 你够了。。。
Dec 12, 2018
Replied to a topic by summersnow521 Java Java DevOps 最贱实践讨论
你是想讨论“最贱实践”还是“最佳实践”?
About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3430 Online   Highest 6679   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 24ms · UTC 12:17 · PVG 20:17 · LAX 05:17 · JFK 08:17
♥ Do have faith in what you're doing.