How We Run as a Non-Root Inside Docker Container

The following text is a partial translation of the original English article, performed by ChatGPT (gpt-3.5-turbo) and this Jekyll plugin:

Docker在其容器内部以“root”用户启动一个进程。然而,在某些情况下,这并不方便。例如,PostgreSQL的initdb不喜欢以root身份启动,会导致失败。在rultor.com中,作为一个DevOps团队助手,我们将Docker作为我们运行的每个构建的虚拟化技术。

以下是我们在容器启动后如何更改用户。

首先,这是我们启动新的Docker容器的方式:

当前目录中有两个文件:entry.shscript.shentry.sh是Docker启动时执行的文件,包含以下内容:

script.sh will be executed as a user r inside the container. And this r user will have sudo permissions. This is exactly what all projects, managing their DevOps procedures with rultor.com, need.

Translated by ChatGPT gpt-3.5-turbo/42 on 2023-12-16 at 15:33

sixnines availability badge   GitHub stars