Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

Merge pull request #2435 from akhilmhdh/doc/docker-integration

Akhil Mohan93afa9123982
diff --cc docs/integrations/platforms/docker.mdx
index 6c059f8dd8,a33c83ba9d..8e429461a2
--- a/docs/integrations/platforms/docker.mdx
+++ b/docs/integrations/platforms/docker.mdx
@@@ -81,8 -81,52 +81,46 @@@ CMD ["infisical", "run", "--projectId"
</Step>
</Steps>
+ ### Using a Starting Script
+
+ The drawback of the previous method is that you would have to generate the `INFISICAL_TOKEN` manually. To automate this process, you can use a shell script as your starting command.
+
+ <Steps>
+ <Step title="Generate a Machine Identity">
+ Create a machine identity for your project by following the steps in the [Machine Identity](/documentation/platform/identities/machine-identities) guide. This identity will enable authentication and secret retrieval from Infisical.
+ </Step>
+
+ <Step title="Create the Shell Script">
+ Create a shell script to obtain an access token for the machine identity:
+
+ ```bash script.sh
+ #!/bin/sh
+ export INFISICAL_TOKEN=$(infisical login --method=universal-auth --client-id=$INFISICAL_MACHINE_CLIENT_ID --client-secret=$INFISICAL_MACHINE_CLIENT_SECRET --plain --silent)
+ exec infisical run --token $INFISICAL_TOKEN --projectId $PROJECT_ID --env $INFISICAL_SECRET_ENV --domain $INFISICAL_API_URL -- <starting script>
+ ```
+
+ > **Note:** The access token has a limited lifespan. Use the [infisical token renew](/cli/commands/token) CLI command to renew it when necessary.
+ <Warning>
+ Caution: Implementing this directly in your Dockerfile presents two key issues:
+
+ 1. Lack of persistence: Variables set in one build step are not automatically carried over to subsequent steps, complicating the process.
+ 2. Security risk: It exposes sensitive credentials inside your container, potentially allowing anyone with container access to retrieve them.
+ </Warning>
+ </Step>
+
+ <Step title="Update Your Dockerfile">
+ Grant the Infisical CLI access to the access token, inside your Docker container. This allows the CLI to fetch and inject secrets into your application.
+
+ Add the following line to your Dockerfile:
+
+ ```dockerfile
+ CMD ["./script.sh"]
+ ```
+ </Step>
+ </Steps>
+
</Tab>
<Tab title="Service Token (Deprecated)">
- <Warning>
-Service tokens are being deprecated in favor of [machine identities](/documentation/platform/identities/machine-identities).
-
-They will be removed in the future in accordance with the deprecation notice and timeline stated [here](https://infisical.com/blog/deprecating-api-keys).
-
-</Warning>
```dockerfile
CMD ["infisical", "run", "--", "[your service start command]"]