问题
I need to store the server_key_rsa of my sftpServer in a docker-compose.yml but I don't know how to store it
It's look like that for now :
-----BEGIN RSA PRIVATE KEY-----
***********************My Key bla bla bla.......
**********************************************
**********************************************
**********************************************
**********************************************
-----END RSA PRIVATE KEY-----
And I would like to store it like that:
server_key_rsa = Here should be the key.
I tried with "|" just before my key, I tried to change my key file to Base64, I tried "\n" between lines, I tried "the\nrsa\nkey", but those solutions failed..
Any idea please ?
回答1:
The secrets definition in the docker-compose.yml file, as of version 3.3 of the file format, does not support passing the content of the secret inside the docker-compose.yml file itself. The secret needs to be either external (predefined with docker secret create secret_name -
) or from the contents of a separate file.
The syntax with an externally defined secret is:
secrets:
my_first_secret:
file: ./secret_data
my_second_secret:
external: true
And the syntax for a separate file containing your secret is:
secrets:
my_first_secret:
file: ./secret_data
my_second_secret:
external:
name: redis_secret
来源:https://stackoverflow.com/questions/46648085/how-to-store-server-key-rsa-in-docker-compose-yml