Integrate with Docker
HCP Vault Secrets allows users to easily setup a secret store to retrieve secrets. This guide walks you through an example configuration to use the vlt CLI with a Docker container.
Prerequisites:
- Docker installed
- An Admin role in an HCP Project
- An HCP Vault Secrets application and secret(s)
Service principal key
Open your web browser and log into the HCP Portal.
Click Access control (IAM) in the HCP Project of your choice.
Click Service principals.
Enter a name in the Service principal name textbox.
Provide the "Viewer" role for reading secret values and click Create service principal.
In the Keys pane, click Create service principal key.
Copy the Client ID and Client secret. These values will be used later to run the Docker container.
Click Vault Secrets and copy the name of the application you want to use with the Docker container.
Docker
Create a
Dockerfile
.Example:
This example builds a Ubuntu image with the CLI installed. Refer to the Install HCP Vault Secrets CLI tutorial for directions to install the CLI for additional operating systems.
Build the image using the
Dockerfile
.Verify the image was created.
Create a environment file with the values collected from the HCP Portal.
Example:
Run the container.
This example lists available secrets to demonstrate the CLI correctly reading the environment file.
Verify the container was able to run the command successfully.
Example output: