我如何在 docker 容器中将用户指定为 root

How can i specify the user as root inside a docker container

我正在尝试在 gitlab-ci 上自动执行加壳命令,所以基本上我是 运行 一个 docker 容器 ubuntu:latest 并尝试使用加壳构建图像.我怎样才能将用户指定为 root?或者我应该如何解决这个错误

请帮忙!

当我尝试执行这个命令时

packer_log=1 packer build image.json

我收到以下错误:

amazon-ebs output will be in this color.

1 error(s) occurred:

* user: could not determine current user from environment.
ERROR: Job failed: exit code 1

出于某种原因,您没有设置 USER 环境变量。您需要正确设置它或使用 ansible 配置器中的 user 配置选项,请参阅文档中的 ansible: user