对于以下 dockerfile:
\n\nFROM buildpack-deps:buster\n\nRUN groupadd -r someteam --gid=1280 && useradd -r -g someteam --uid=1280 --create-home --shell /bin/bash someteam\n\n# Update and allow for apt over HTTPS\nRUN apt-get update && \\\n apt-get install -y apt-utils\nRUN apt-get install -y apt-transport-https\nRUN apt update -y \nRUN apt install python3-pip -y\n\n# switch user from 'root' to \xe2\x80\x98someteam\xe2\x80\x99 and also to the home directory that it owns \nUSER someteam\n\nRUN pwd \nRun Code Online (Sandbox Code Playgroud)\n\nUSER只更改用户但不更改主目录
Step 11/14 : WORKDIR $HOME\ncannot normalize nothing\nRun Code Online (Sandbox Code Playgroud)\n\n如何将主目录更改为/home/someteam?
您可以WORKDIR在 dockerfile 中使用更改用户目录,这将成为工作目录。因此,每当您创建容器时,工作目录都将是传递给WORKDIRDockerfile 中的指令的目录。
工作目录
\n\nWORKDIR 指令的 Dockerfile 参考
\n\n\n\n\n为了清晰和可靠,您应该始终使用 WORKDIR 的绝对路径。另外,您应该使用 WORKDIR 而不是大量的指令,例如 RUN cd \xe2\x80\xa6 && do-something,这些指令难以阅读、故障排除和维护。
\n
FROM buildpack-deps:buster\n\nRUN groupadd -r someteam --gid=1280 && useradd -r -g someteam --uid=1280 --create-home --shell /bin/bash someteam\n\n# Update and allow for apt over HTTPS\nRUN apt-get update && \\\n apt-get install -y apt-utils\nRUN apt-get install -y apt-transport-https\nRUN apt update -y \nRUN apt install python3-pip -y\n\n# switch user from \'root\' to \xe2\x80\x98someteam\xe2\x80\x99 and also to the home directory that it owns \nUSER someteam\nWORKDIR /home/someteam\nRun Code Online (Sandbox Code Playgroud)\n\n\n\n使用 $HOME 会导致错误。
\n\n\n\n当您使用 USER 指令时,它会影响用于在容器内启动新命令的用户 ID。最好的选择是在 Dockerfile 中设置 ENV\n HOME /home/aptly,这将起作用dockerfile-home-is-不使用添加复制指令
\n
| 归档时间: |
|
| 查看次数: |
21886 次 |
| 最近记录: |