使用命令输出作为环境variables值?

我想要复制用户的GID和UID以使用这些值在映像中创build新用户,以便修复卷的权限问题。

我已经find了解释如何做的答案 。

但我也想在我docker-compose.yml文件中dynamic地执行它。

为了实现这一点,我想dynamic检索这些值通过使用命令输出。 但是我不知道docker撰写文件是否可能。

我试过这个:

  args: - GIT_UID="$(grep git /etc/passwd | cut -d : -f 3)" - GIT_GID="$(grep git /etc/passwd | cut -d : -f 4)" 

并尝试了一些变体。

但到目前为止,我没有成功,使得它的工作,我得到这个错误:

 ERROR: The Compose file './docker-compose.yml' is invalid because: services.gogs.environment contains {"GIT_UID=\"$(grep git /etc/passwd | cut -d": "-f 3)\""}, which is an invalid type, it should be a string 

是否有可能使用一个命令输出作为一个环境variables的值与docker-compose文件,如果是的话我该怎么办?