Forrest logo
back to the docker tool

docker:tldr:bd475

docker: Create a new secret from a file.
$ docker secret create ${secret_name} ${filename}
try on your machine

The command docker secret create is used to create a secret in Docker. A secret is secure data that can be accessed by Docker services, but not directly visible or accessible by containers. Secrets are typically used to store sensitive information such as passwords, API keys, or certificates.

In the given command, ${secret_name} is a placeholder for the name you want to give to the secret. This name is unique within the Docker swarm and can be used to reference the secret later.

${filename} is a placeholder for the path to the file containing the secret's data. The file can contain any kind of data, such as text or binary. The contents of the file will be stored as the secret.

For example, if you want to create a secret named "db_password" with a file named "password.txt" containing the actual password, the command would look like:

docker secret create db_password password.txt

After running this command, the secret will be created and can be referenced by Docker services or containers using its name.

This explanation was created by an AI. In most cases those are correct. But please always be careful and never run a command you are not sure if it is safe.
back to the docker tool