如何将server_key_rsa存入docker-compose.yml?

How to store server_key_rsa in docker-compose.yml?

我需要将我的 sftpServer 的 server_key_rsa 存储在 docker-compose.yml 中,但我不知道如何存储它

目前看起来是这样:

-----BEGIN RSA PRIVATE KEY-----
***********************My Key bla bla bla.......
**********************************************
**********************************************
**********************************************
**********************************************
-----END RSA PRIVATE KEY-----

我想这样存储它:

server_key_rsa = 这里应该是关键。

我试过用“|”就在我的密钥之前,我试图将我的密钥文件更改为 Base64,我尝试在行之间使用“\n”,我尝试了 "the\nrsa\nkey",但这些解决方案失败了..

有什么想法吗?

从文件格式的 3.3 版开始,secrets definition in the docker-compose.yml file 不支持在 docker-compose.yml 文件本身中传递秘密内容。秘密需要是外部的(使用 docker secret create secret_name - 预定义)或来自单独文件的内容。

具有外部定义的秘密的语法是:

secrets:
  my_first_secret:
    file: ./secret_data
  my_second_secret:
    external: true

包含您的秘密的单独文件的语法是:

secrets:
  my_first_secret:
    file: ./secret_data
  my_second_secret:
    external:
      name: redis_secret