# ./launcher rebuild 命令在 app.yml 包含长环境变量时失败

**URL:** https://meta.discourse.org/t/launcher-rebuild-command-fails-when-app-yml-contains-a-long-env-variable/162381
**Category:** Support
**Created:** [2020年八月28日 19:27 UTC](https://meta.discourse.org/t/launcher-rebuild-command-fails-when-app-yml-contains-a-long-env-variable/162381 "2020-08-28T19:27:24Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![Stefan\_Brighiu\_M](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/stefan_brighiu_m/32/174499_2.png) [@Stefan\_Brighiu\_M](https://meta.discourse.org/u/Stefan_Brighiu_M)
#### Post date: [2020年八月28日 19:27 UTC](https://meta.discourse.org/t/launcher-rebuild-command-fails-when-app-yml-contains-a-long-env-variable/162381/1 "2020-08-28T19:27:24Z")

</div>

我试图通过 app.yml 将私钥添加到环境变量中。

添加后，一切都无法正常工作。如果将其移除，系统似乎又恢复正常。

我尝试添加的值如下所示，是一行包含 1755 个字符的字符串：

> PRIVATE\_KEY: “-----BEGIN PRIVATE KEY-----\n…\n…\n-----END PRIVATE KEY-----\n”

我该如何修复这个问题？

```
> 确保启动器为最新版本
> 
> 获取远程仓库
> 
> remote: Enumerating objects: 7, done.
> 
> remote: Counting objects: 100% (7/7), done.
> 
> remote: Compressing objects: 100% (4/4), done.
> 
> remote: Total 4 (delta 2), reused 0 (delta 0), pack-reused 0
> 
> Unpacking objects: 100% (4/4), done.
> 
> 来自 gitlab.com: REPO
> 
> 6075498..d46af48 master -> origin/master
> 
> 更新启动器
> 
> 更新 6075498..d46af48
> 
> Fast-forward
> 
> containers/app.yml | 6 ++----
> 
> 1 file changed, 2 insertions(+), 4 deletions(-)
> 
> 确保启动器为最新版本
> 
> 获取远程仓库
> 
> 启动器已是最新版本
> 
> 停止旧容器
> 
> + /usr/bin/docker stop -t 60 app
> 
> app
> 
> cd /pups && git pull && /pups/bin/pups --stdin
> 
> /usr/bin/docker: 无效的引用格式：仓库名称必须为小写。
> 
> 请查看 '/usr/bin/docker run --help'。
> 
> cat: cids/app_bootstrap.cid: 没有那个文件或目录
> 
> "docker rm" 至少需要一个参数。
> 
> 请查看 'docker rm --help'。
> 
> 用法：docker rm [OPTIONS] CONTAINER [CONTAINER...]
> 
> 删除一个或多个容器
> 
> rm: 无法删除 'cids/app_bootstrap.cid': 没有那个文件或目录
> 
> **引导失败** 请向上滚动并查找更早的错误信息，可能不止一条。
> 
> ./discourse-doctor 可能有助于诊断问题。

```

---

<div class="post-metadata">

### Author: ![Stephen](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/stephen/32/95011_2.png) [@Stephen](https://meta.discourse.org/u/Stephen)
#### Post date: [2020年八月28日 19:47 UTC](https://meta.discourse.org/t/launcher-rebuild-command-fails-when-app-yml-contains-a-long-env-variable/162381/2 "2020-08-28T19:47:14Z")

</div>

你移除换行符了吗？能否用 `\n` 代替？

将私钥存储在单独的文件中并传入。

---

<div class="post-metadata">

### Author: ![Stefan\_Brighiu\_M](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/stefan_brighiu_m/32/174499_2.png) [@Stefan\_Brighiu\_M](https://meta.discourse.org/u/Stefan_Brighiu_M)
#### Post date: [2020年八月28日 19:49 UTC](https://meta.discourse.org/t/launcher-rebuild-command-fails-when-app-yml-contains-a-long-env-variable/162381/3 "2020-08-28T19:49:52Z")

</div>

@Stephen 你能帮我吗？

如果 file.json 和 app.yml 在同一个目录下，app.yml 中的那一行应该怎么写？

我创建了 27 个变量……每个都以换行符结尾。显然，它不接受变量中包含两个换行符，但我又不能像现在这样使用。我需要将其放在一个特定名称的环境变量中。

---

<div class="post-metadata">

### Author: ![supermathie](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/supermathie/32/507518_2.png) [@supermathie](https://meta.discourse.org/u/supermathie)
#### Post date: [2020年八月29日 00:31 UTC](https://meta.discourse.org/t/launcher-rebuild-command-fails-when-app-yml-contains-a-long-env-variable/162381/4 "2020-08-29T00:31:55Z")

</div>

你试过使用多行 YAML 吗？

> **[YAML Multiline Strings](https://yaml-multiline.info/)**
>
> Find the right syntax for your YAML multiline strings.

---

<div class="post-metadata">

### Author: ![Stefan\_Brighiu\_M](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/stefan_brighiu_m/32/174499_2.png) [@Stefan\_Brighiu\_M](https://meta.discourse.org/u/Stefan_Brighiu_M)
#### Post date: [2020年八月29日 06:58 UTC](https://meta.discourse.org/t/launcher-rebuild-command-fails-when-app-yml-contains-a-long-env-variable/162381/5 "2020-08-29T06:58:07Z")

</div>

我尝试过使用 | 格式，因为我需要保留换行符。但这导致了另一个错误，似乎是关于注释的问题。于是我改用调用 ./launcher 命令时添加 --env-file docker\_args 参数。它确实为环境变量赋值了，但我需要确认是否正确。

generated cert.env 文件中只包含一个环境变量，即 cert。

我稍后会回来更新进展，等我检查后再说。

---

<div class="post-metadata">

### Author: ![Stefan\_Brighiu\_M](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/stefan_brighiu_m/32/174499_2.png) [@Stefan\_Brighiu\_M](https://meta.discourse.org/u/Stefan_Brighiu_M)
#### Post date: [2020年八月30日 08:21 UTC](https://meta.discourse.org/t/launcher-rebuild-command-fails-when-app-yml-contains-a-long-env-variable/162381/6 "2020-08-30T08:21:22Z")

</div>

嗯，看起来有效。我会进行更多测试，但目前我认为这是一个不错的解决方案。
