Skip to content
This repository has been archived by the owner on Aug 17, 2021. It is now read-only.

02 Use Secrets

satrapu edited this page Oct 14, 2017 · 4 revisions

This page details how to provide secrets to a container.
Passing sensitive data (e.g. credentials, certificates, etc.) to containers should be done in a secured manner and Rancher offers support for this kind of activity.

More information can be found here.

  1. Go to Rancher UI
  2. Go to menu → Stacks → User
  3. Click "Add from catalog"
  4. Filter catalog items by "rancher secrets"
  5. Click the "View Details" button
  6. Leave all fields set to default values and click "Launch" button
  7. Go to menu → Infrastructure → Secrets
  8. Click "Add Secret" button
  9. Fill in the fields accordingly
    1. Name: tgd5
    2. Description: Java Tech Group #5 Secret
    3. Secret Value: rancher-workshop
  10. Click "Save" button and you should see the newly added secret
  11. Go to menu → Infrastructure → Containers
  12. Click the top left "Add Container" button
  13. Fill in the fields in order to start a container based on the alpine Docker image
    1. Name: alpine
    2. Description: My first adhoc container running on Rancher!
    3. Image: alpine
    4. Command tab → Command: tail -f /dev/null
      1. This will force the container to remain in running state after start-up so that one may execute shell commands, view container logs or interact with it in other any way
    5. Secrets tab → Add Secret: choose tgd5 and optionally can set an alias, via As Name field
      If the "As Name" field was not set, the secret will be available at path: /run/secrets/tgd5.
      If the "As Name" field was set to "my_secret", the secret value will be available at path: /run/secrets/my_secret.
  14. Click the "Create" button
  15. Once the container is running, go to container top right menu and select "Execute Shell"
  16. Inside the console, type "cat /run/secrets/my_secret" to print the secret value
Clone this wiki locally