Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.
TypeScript acmeagentsai-agentscertificate-managementdevsecopsenvironment-variableskubernetesopen-sourcepampkipostgresprivate-caprivileged-access-managementsecret-managementsecret-managersecretssecrets-managementsecuritysecurity-toolsvault
docs(integrations): rewrite docker guide (#7571)
Adrian Kahalib9924672e8c9
diff --git a/docs/cli/usage.mdx b/docs/cli/usage.mdxindex 42535d9cb4..1011de3562 100644--- a/docs/cli/usage.mdx+++ b/docs/cli/usage.mdx@@ -114,7 +114,7 @@ The CLI is designed for a variety of secret management applications ranging from</Step></Steps>- For Docker Compose and `--env-file` workflows, see the [Docker guides](/integrations/platforms/docker-intro).+ For Docker Compose and `--env-file` workflows, see the [Docker guide](/integrations/platforms/docker).</Tab>diff --git a/docs/docs.json b/docs/docs.jsonindex 66608e3ac9..0948c43f91 100644--- a/docs/docs.json+++ b/docs/docs.json@@ -702,15 +702,7 @@{"group": "Infrastructure","pages": [- {- "group": "Docker",- "pages": [- "integrations/platforms/docker-intro",- "integrations/platforms/docker",- "integrations/platforms/docker-pass-envs",- "integrations/platforms/docker-compose"- ]- },+ "integrations/platforms/docker","integrations/platforms/ansible","integrations/platforms/apache-airflow",{@@ -4394,7 +4386,7 @@},{"label": "Docker",- "href": "https://infisical.com/docs/integrations/platforms/docker-intro"+ "href": "https://infisical.com/docs/integrations/platforms/docker"},{"label": "AWS ECS",@@ -4503,6 +4495,18 @@}},"redirects": [+ {+ "source": "/integrations/platforms/docker-intro",+ "destination": "/integrations/platforms/docker"+ },+ {+ "source": "/integrations/platforms/docker-pass-envs",+ "destination": "/integrations/platforms/docker"+ },+ {+ "source": "/integrations/platforms/docker-compose",+ "destination": "/integrations/platforms/docker"+ },{"source": "/documentation/platform/agent-proxy/quickstart","destination": "/documentation/platform/agent-proxy/quickstart/credentials"diff --git a/docs/documentation/getting-started/docker.mdx b/docs/documentation/getting-started/docker.mdxindex 56cc624c38..3d303dc6e6 100644--- a/docs/documentation/getting-started/docker.mdx+++ b/docs/documentation/getting-started/docker.mdx@@ -179,7 +179,4 @@ Prerequisites:</Tab></Tabs>-See also:--- [Documentation for Docker](/integrations/platforms/docker)-- [Documentation for Docker Compose](/integrations/platforms/docker-compose)+See the [Docker secrets delivery guide](/integrations/platforms/docker) for the recommended startup, Docker Run, and Docker Compose workflows.diff --git a/docs/documentation/platform/secrets-mgmt/quick-starts/deliver-first-secret.mdx b/docs/documentation/platform/secrets-mgmt/quick-starts/deliver-first-secret.mdxindex 4b2aae6e6e..3d74a57c35 100644--- a/docs/documentation/platform/secrets-mgmt/quick-starts/deliver-first-secret.mdx+++ b/docs/documentation/platform/secrets-mgmt/quick-starts/deliver-first-secret.mdx@@ -4,6 +4,8 @@ sidebarTitle: "Inject secrets locally"description: "Store secrets in Infisical and deliver them to your local application without a `.env` file."---+import ConfigureProject from "/snippets/documentation/platform/secrets-mgmt/configure-project.mdx";+This quickstart guide walks you through the recommended secrets management workflow for local development. You'll create a [project](/documentation/platform/secrets-mgmt/project), add secrets to one of its environments, and inject them into your local application using the [Infisical CLI](/cli/overview), all without needing a `.env` file.<Info>@@ -14,84 +16,7 @@ Prerequisites:- An application or script you run locally</Info>-## Step 1: Configure in Infisical--### Create a project--In Infisical, a [project](/documentation/platform/secrets-mgmt/project) holds all secrets for one application or service. To create a project:--<Steps>- <Step>- Log in to [Infisical](https://app.infisical.com).- </Step>- <Step>- Select **Secrets Management** > **+ Add New Project**.- </Step>- <Step>- In the **Project Name** field, enter a name for the project (e.g., `orders-service`).- </Step>- <Step>- Select **Create Project**.- </Step>-</Steps>--This opens your new project in the **Development** environment:--<Frame>- -</Frame>--<Note>- Within a project, secrets are organized across [environments](/documentation/platform/secrets-mgmt/project#project-environments). Every new project starts with three environments: **Development**, **Staging**, and **Production**.-</Note>--### Add your secrets--You have two options for adding secrets to your project:--<Tabs>- <Tab title="Create secrets manually">- To create a new secret from scratch:-- <Steps>- <Step>- Select **+ Add a New Secret**.- </Step>- <Step>- In the **Key** and **Value** fields, enter a key-value pair. For example:-- <Frame>- - </Frame>- </Step>- <Step>- Select **Create Secret**.- </Step>- <Step>- Repeat these steps for each key-value pair you want to add.- </Step>- </Steps>- </Tab>- <Tab title="Import secrets from an existing file">- To import secrets from an existing file:-- <Steps>- <Step>- Drag and drop the file containing your secrets (or enter the file's contents manually by selecting **Paste Secrets**).- </Step>- <Step>- Review the discovered secrets. For example:-- <Frame>- - </Frame>- </Step>- <Step>- Select **Upload Secrets**.- </Step>- </Steps>- </Tab>-</Tabs>+<ConfigureProject />## Step 2: Connect your app to Infisicaldiff --git a/docs/integrations/platforms/docker-compose.mdx b/docs/integrations/platforms/docker-compose.mdxdeleted file mode 100644index 09bd82ff7d..0000000000--- a/docs/integrations/platforms/docker-compose.mdx+++ /dev/null@@ -1,100 +0,0 @@-----title: "Docker Compose"-description: "Find out how to use Infisical to inject environment variables into services defined in your Docker Compose file."------Prerequisites:--- Set up and add envars to [Infisical Cloud](https://app.infisical.com)--## Configure the Infisical CLI for each service--Follow this [guide](./docker) to configure the Infisical CLI for each service that you wish to inject environment variables into; you'll have to update the Dockerfile of each service.--<Tabs>- <Tab title="Machine Identity (Recommended)">- ### Generate and configure machine identity- Generate a machine identity for each service you want to inject secrets into. You can do this by following the steps in the [Machine Identity](/documentation/platform/identities/machine-identities) guide.-- ### Set the machine identity client ID and client secret as environment variables- For each service you want to inject secrets into, generate the required `INFISICAL_TOKEN_SERVICE_A` and `INFISICAL_TOKEN_SERVICE_B`.-- ```yaml- # Example Docker Compose file- services:- web:- build: .- image: example-service-1- environment:- - INFISICAL_TOKEN=${INFISICAL_TOKEN_SERVICE_A}-- api:- build: .- image: example-service-2- environment:- - INFISICAL_TOKEN=${INFISICAL_TOKEN_SERVICE_B}-- ```-- ### Export shell variables- Next, set the shell variables you defined in your compose file. This can be done manually or via your CI/CD environment. Once done, it will be used to populate the corresponding `INFISICAL_TOKEN_SERVICE_A` and `INFISICAL_TOKEN_SERVICE_B` in your Docker Compose file.-- ```bash- #Example-- # Token refers to the token we generated in step 2 for this service- export INFISICAL_TOKEN_SERVICE_A=$(infisical login --method=universal-auth --client-id=<your-client-id> --client-secret=<your-client-secret> --silent --plain)- export INFISICAL_TOKEN_SERVICE_B=$(infisical login --method=universal-auth --client-id=<your-client-id> --client-secret=<your-client-secret> --silent --plain)-- # Then run your compose file in the same terminal.- docker-compose ...- ```-- </Tab>- <Tab title="Service Token">-- ## Generate service token- Generate a unique [Service Token](/documentation/platform/token) for each service.-- ## Feed service token to your Docker Compose file-- For each service you want to inject secrets into, set an environment variable called `INFISICAL_TOKEN` equal to a unique identifier variable.-- In the example below, we set `INFISICAL_TOKEN_FOR_WEB` and `INFISICAL_TOKEN_FOR_API` as the `INFISICAL_TOKEN` for the services.-- ```yaml- # Example Docker Compose file- services:- web:- build: .- image: example-service-1- environment:- - INFISICAL_TOKEN=${INFISICAL_TOKEN_FOR_WEB}-- api:- build: .- image: example-service-2- environment:- - INFISICAL_TOKEN=${INFISICAL_TOKEN_FOR_API}- ```-- ## Export shell variables-- Next, set the shell variables you defined in your compose file. This can be done manually or via your CI/CD environment. Once done, it will be used to populate the corresponding `INFISICAL_TOKEN`- in your Docker Compose file.-- ```bash- #Example-- # Token refers to the token we generated in step 2 for this service- export INFISICAL_TOKEN_FOR_WEB=<token>-- # Token refers to the token we generated in step 2 for this service- export INFISICAL_TOKEN_FOR_API=<token>-- # Then run your compose file in the same terminal.- docker-compose ...- ```-- </Tab>-</Tabs>diff --git a/docs/integrations/platforms/docker-intro.mdx b/docs/integrations/platforms/docker-intro.mdxdeleted file mode 100644index e4cdb3a086..0000000000--- a/docs/integrations/platforms/docker-intro.mdx+++ /dev/null@@ -1,41 +0,0 @@-----title: "Docker"-description: "Learn how to feed secrets from Infisical into your Docker application."-----There are many methods to inject Infisical secrets into Docker-based applications.-Regardless of the method you choose, they all inject secrets from Infisical as environment variables into your Docker container.--Watch the video below for an overview of managing environment variables in Docker, covering Docker Compose, Docker secrets, and injection with the Infisical CLI.--<br />--<div style={{ position: "relative", paddingBottom: "56.25%", height: 0, overflow: "hidden", maxWidth: "100%" }}>- <iframe- src="https://www.youtube.com/embed/oU2nNBwlOTA"- title="YouTube video player"- style={{ position: "absolute", top: 0, left: 0, width: "100%", height: "100%", border: 0 }}- allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share"- allowfullscreen- ></iframe>-</div>--<br />--<Card title="Docker Entrypoint" color="#ea5a0c" href="./docker">- Install and run your app start command with Infisical CLI-</Card>-<CardGroup cols={2}>- <Card title="Docker run" color="#0285c7" href="./docker-pass-envs">- Feed secrets with the `--env-file` flag when using the- `docker run` command- </Card>- <Card title="Docker compose" color="#16a34a" href="./docker-compose">- Inject secrets into multiple services using Docker Compose- </Card>-</CardGroup>--<Info>-The main difference between the "Docker Entrypoint" and "Docker run" approach is where the Infisical CLI is installed.-In most production settings, it's typically less convenient to have the Infisical CLI installed and executed externally, so we suggest using the "Docker Entrypoint" method for production purposes.-However, if this limitation doesn't apply to you, select the method that best fits your needs.-</Info>\ No newline at end of filediff --git a/docs/integrations/platforms/docker-pass-envs.mdx b/docs/integrations/platforms/docker-pass-envs.mdxdeleted file mode 100644index cf595de3d6..0000000000--- a/docs/integrations/platforms/docker-pass-envs.mdx+++ /dev/null@@ -1,57 +0,0 @@-----title: "Docker Run"-description: "Learn how to pass secrets to your docker container at run time."------This method allows you to feed secrets from Infisical into your container using the `--env-file` flag of `docker run` command.-Rather than giving the flag a file path to your env file, you'll use the Infisical CLI to create a virtual file path.--For this method to function as expected, you must have a bash shell (for processing substitution) and the [Infisical CLI](../../cli/overview) installed in the environment where you will be running the `docker run` command.--## 1. Authentication--If you are already logged in via the CLI you can skip this step. Otherwise, head to your organization settings in Infisical Cloud to create a [Machine Identity](../../documentation/platform/identities/machine-identities). The machine identity will allow you to authenticate and fetch secrets from Infisical.-Once you have created a machine identity with the required permissions, you'll need to feed the token to the CLI.-<Info>- Please note that we highly recommend using `infisical login` for local development.-</Info>--#### Pass as flag-You may use the --token flag to set the token--```bash-infisical export --token=<>-```--#### Pass via shell environment variable-The CLI is configured to look for an environment variable named `INFISICAL_TOKEN`. If set, it'll attempt to use it for authentication.--```bash-export INFISICAL_TOKEN=<>-```--You can use the `infisical login --method=universal-auth` command to directly obtain a universal auth access token and set it as an environment variable.--```bash- export INFISICAL_TOKEN=$(infisical login --method=universal-auth --client-id=<your-client-id> --client-secret=<your-client-secret> --silent --plain)-```--<Warning>- In production scenarios, please to avoid using the `infisical login` command and instead use a [machine identity](../../documentation/platform/identities/machine-identities).-</Warning>--## 2. Run your docker command with Infisical-Next, use the --env-file flag of the `docker run` command with Infisical CLI to point to your secrets.-Under the hood, this command will fetch secrets from Infisical and serve them as a file to the `--env-file` flag.--```bash-# In this example, executing a docker run command will initiate an empty Alpine container and display the environment variables passed to it by Infisical.-docker run --rm --env-file <(infisical export --format=dotenv) alpine printenv-```--To view all options of the `export` command, click [here](../../cli/commands/export)---<Warning>- When using the --env-file option, Docker does not have the capability to support secrets that span multiple lines.-</Warning>diff --git a/docs/integrations/platforms/docker.mdx b/docs/integrations/platforms/docker.mdxindex 9be0d1d81b..5d6f70d8f7 100644--- a/docs/integrations/platforms/docker.mdx+++ b/docs/integrations/platforms/docker.mdx@@ -1,130 +1,459 @@----title: "Docker Entrypoint"-description: "Learn how to use Infisical to inject environment variables into a Docker container."+title: "Inject secrets into a Docker application"+sidebarTitle: "Docker"+description: "Store secrets in Infisical and deliver them to a Dockerized application at runtime."----This approach allows you to inject secrets from Infisical directly into your application.-This is achieved by installing the Infisical CLI into your docker image and modifying your start command to execute with Infisical.+import ConfigureProject from "/snippets/documentation/platform/secrets-mgmt/configure-project.mdx";-## Install the Infisical CLI to your Dockerfile+This guide walks you through storing secrets in Infisical and injecting them into a Dockerized application as environment variables. You can [fetch secrets when the container starts](#fetch-at-startup) or [export them from the host](#pass-with-docker-run) when you run the container.-To install the CLI, follow the instructions for your chosen distribution [here](/cli/overview).--####<Tip>- We recommend you to set the version of the CLI to a specific version. This will help keep your CLI version consistent across reinstalls. [View versions](https://github.com/Infisical/cli/releases)+ Visual learner? Watch an [overview of managing secrets in Docker with Infisical](https://www.youtube.com/watch?v=oU2nNBwlOTA).</Tip>-## Modify the start command in your Dockerfile+<Info>+Prerequisites:++- An Infisical account on [Infisical Cloud](https://app.infisical.com) or a [self-hosted instance](/self-hosting/overview)+- [Docker](https://docs.docker.com/get-started/get-docker/) installed+- The [Infisical CLI](/cli/overview) installed on the machine where you run Docker+- An application or container image to run+</Info>++<ConfigureProject />++## Step 2: Choose a delivery method-Starting your service with the Infisical CLI pulls your secrets from Infisical and injects them into your service.+Next, choose how Docker should receive your application secrets:<Tabs>- <Tab title="Machine Identity (Recommended)">- ```dockerfile- CMD ["infisical", "run", "--projectId", "<your-project-id>", "--", "[your service start command]"]+ <Tab title="Fetch at startup (Recommended)">+ <span id="fetch-at-startup"></span>++ This method installs the Infisical CLI in your image and uses it to start your application. The CLI fetches secrets when the container starts and injects them into the application process.++ <Note>+ We strongly recommend this method, since it works for both local development and automated/production environments.+ </Note>++ ### Create a machine identity++ Create a [machine identity](/documentation/platform/identities/machine-identities) for your application:++ <Steps>+ <Step>+ In your project, select **Project Settings** > **Access Control** > **Machine Identities**.+ </Step>+ <Step>+ Select **Add Machine Identity**, then select **Create New**.+ </Step>+ <Step>+ Enter a name (e.g., `orders-service-docker`), select a role that can read secrets, and select **Create**.+ </Step>+ </Steps>++ Infisical creates the identity with [Universal Auth](/documentation/platform/identities/universal-auth) enabled and opens its details page.++ ### Create a client secret++ Create credentials that the application can exchange for a short-lived access token:++ <Steps>+ <Step>+ In the machine identity's **Authentication** section, select **Universal Auth**.+ </Step>+ <Step>+ Copy the **Client ID** and save it somewhere secure for the next step.+ </Step>+ <Step>+ Select **Create Client Secret**, enter a description (e.g., `docker-quickstart`), and select **Create**.+ </Step>+ <Step>+ Copy the **Client Secret**. You won't be able to view it again.+ </Step>+ </Steps>++ <Warning>+ Don't add the Client ID, Client Secret, or an Infisical access token to your Dockerfile. Docker images may be shared or stored in a registry.+ </Warning>++ <Note>+ Machine identity access tokens are short-lived. Token expiration doesn't affect an application after `infisical run` has fetched its secrets, but the container needs a valid token every time it starts.++ In automated deployments, store the Client ID and Client Secret in your deployment platform's secret store and run `infisical login` immediately before each `docker run` or `docker compose up`.+ </Note>++ ### Copy your project ID++ In your project, select **Project Settings**, then select **Copy Project ID**. You'll add this ID to your Dockerfile in the next step.++ ### Update your Dockerfile++ Add the Infisical CLI installation that matches your base image:++ <CodeGroup>+ ```dockerfile Alpine+ RUN apk add --no-cache bash wget \+ && wget -qO- 'https://artifacts-cli.infisical.com/setup.apk.sh' | sh \+ && apk add --no-cache infisical+ ```++ ```dockerfile Debian or Ubuntu+ RUN apt-get update \+ && apt-get install -y --no-install-recommends bash curl ca-certificates \+ && curl -1sLf 'https://artifacts-cli.infisical.com/setup.deb.sh' | bash \+ && apt-get update \+ && apt-get install -y --no-install-recommends infisical \+ && rm -rf /var/lib/apt/lists/*+ ```+ </CodeGroup>-# example with single single command+ <Tip>+ Pin the [Infisical CLI version](https://github.com/Infisical/cli/releases) in production images to keep builds reproducible.+ </Tip>++ Next, wrap your application's start command with [`infisical run`](/cli/commands/run). Replace `<project-id>` with the project ID you copied earlier:++ <CodeGroup>+ ```dockerfile Node.js+ CMD ["infisical", "run", "--projectId=<project-id>", "--env=dev", "--", "npm", "start"]+ ```++ ```dockerfile Flask+ CMD ["infisical", "run", "--projectId=<project-id>", "--env=dev", "--", "flask", "run", "--host=0.0.0.0"]+ ```++ ```dockerfile Go+ CMD ["infisical", "run", "--projectId=<project-id>", "--env=dev", "--", "./app"]+ ```+ </CodeGroup>-CMD ["infisical", "run", "--projectId", "<your-project-id>", "--", "npm", "run", "start"]+ <Accordion title="Run multiple startup commands">+ Use the [`--command` option](/cli/commands/run#infisical-run:command) when your application needs to run multiple shell commands in sequence:-# example with multiple commands+ ```dockerfile+ CMD ["infisical", "run", "--projectId=<project-id>", "--env=dev", "--command", "npm run migrate && npm start"]+ ```+ </Accordion>-CMD ["infisical", "run", "--projectId", "<your-project-id>", "--command", "npm run start && ..."]+ ### Build and run your container-````+ Build your image:-<Steps>- <Step title="Generate a machine identity">- Generate a machine identity for your project by following the steps in the [Machine Identity](/documentation/platform/identities/machine-identities) guide. The machine identity will allow you to authenticate and fetch secrets from Infisical.- </Step>- <Step title="Obtain an access token for the machine identity">- Obtain an access token for the machine identity by running the following command:```bash- export INFISICAL_TOKEN=$(infisical login --method=universal-auth --client-id=<your-client-id> --client-secret=<your-client-secret> --plain --silent)+ docker build -t orders-service .```- <Info>- Please note that the access token has a limited lifespan. The `infisical token renew` command can be used to renew the token if needed.- </Info>- </Step>- <Step title="Feed the access token to the docker container">- The last step is to give the Infisical CLI installed in your Docker container access to the access token. This will allow the CLI to fetch and inject the secrets into your application.+ On the machine where Docker runs, authenticate the machine identity and start the container using the commands for your Infisical deployment:++ <CodeGroup>+ ```bash Infisical Cloud US+ export INFISICAL_TOKEN=$(infisical login \+ --method=universal-auth \+ --client-id=<client-id> \+ --client-secret=<client-secret> \+ --plain \+ --silent)++ docker run --rm --env INFISICAL_TOKEN orders-service+ ```++ ```bash EU Cloud or self-hosted+ # Use https://eu.infisical.com for EU Cloud or your self-hosted instance URL+ export INFISICAL_DOMAIN=<your-infisical-domain>++ export INFISICAL_TOKEN=$(infisical login \+ --method=universal-auth \+ --client-id=<client-id> \+ --client-secret=<client-secret> \+ --plain \+ --silent)++ docker run --rm --env INFISICAL_TOKEN --env INFISICAL_DOMAIN orders-service+ ```+ </CodeGroup>++ <Note>+ If your self-hosted Infisical instance is running locally on the Docker host, don't set `INFISICAL_DOMAIN` to a `localhost` URL, since this will point to the container itself.++ Instead, set it to a `host.docker.internal` URL, [which points to the container's host domain](https://docs.docker.com/desktop/features/networking/networking-how-tos/#connect-a-container-to-a-service-on-the-host).+ </Note>++ Replace `<client-id>` and `<client-secret>` with the machine identity credentials you created earlier. The access token is passed to the container at runtime and isn't stored in the image.++ <Check>+ Your application can now read secrets as environment variables when the container starts.+ </Check>+ </Tab>++ <Tab title="Docker Run (Interactive)">+ <span id="pass-with-docker-run"></span>+ <span id="docker-run-interactive"></span>++ Alternatively, you can run the Infisical CLI on the host and pass exported secrets to an existing image through Docker's `--env-file` option. This method doesn't require you to install the CLI in the image.- To feed the access token to the container, use the INFISICAL_TOKEN environment variable as shown below.+ <Note>+ This method requires a Bash-compatible shell because it uses process substitution.+ </Note>++ ### Authenticate with the CLI++ Authenticate with Infisical by running [`infisical login`](/cli/commands/login):```bash- docker run --env INFISICAL_TOKEN=$INFISICAL_TOKEN [DOCKER-IMAGE]...+ infisical login```- </Step>-</Steps>-### Using a Starting Script+ This prompts you to select your hosting option, then opens your browser to complete the login.++ ### Connect your project++ In your application's directory, link it to the project you created by running [`infisical init`](/cli/commands/init):++ ```bash+ infisical init+ ```-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.+ Follow the prompts to select your organization and project.-<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>+ ### Run your container- <Step title="Create the Shell Script">- Create a shell script to obtain an access token for the machine identity:+ Export the secrets from the **Development** environment and pass them to your container:- ```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>+ ```bash+ docker run --rm \+ --env-file <(infisical export --env=dev --format=dotenv) \+ orders-service```- > **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:+ Replace `orders-service` with the image you want to run. Infisical serves the exported secrets through a temporary file descriptor rather than writing a `.env` file to disk.++ <Warning>+ Docker's `--env-file` option doesn't support multiline secret values. Use the startup method if your application requires multiline secrets.+ </Warning>- 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>+ <Check>+ Your container can now read the exported secrets as environment variables.+ </Check>+ </Tab>- <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.+ <Tab title="Docker Run (CI/CD)">+ <span id="docker-run-cicd"></span>- Add the following line to your Dockerfile:+ In CI/CD and other automated environments, use a [machine identity](/documentation/platform/identities/machine-identities) to authenticate the Infisical CLI on the host. The CLI exports your application secrets and passes them to an existing image through Docker's `--env-file` option.- ```dockerfile- CMD ["./script.sh"]- ```- </Step>-</Steps>--</Tab>-<Tab title="Service Token (Deprecated)">-```dockerfile-CMD ["infisical", "run", "--", "[your service start command]"]--# example with single single command-CMD ["infisical", "run", "--", "npm", "run", "start"]--# example with multiple commands-CMD ["infisical", "run", "--command", "npm run start && ..."]-````-- <Steps>- <Step title="Generate a service token">- Head to your project settings in the Infisical dashboard to generate an [service token](/documentation/platform/token).- This service token will allow you to authenticate and fetch secrets from Infisical.- Once you have created a service token with the required permissions, you’ll need to feed the token to the CLI installed in your docker container.- </Step>- <Step title="Feed service token to docker container">- The last step is to give the Infisical CLI installed in your Docker container access to the service token. This will allow the CLI to fetch and inject the secrets into your application.-- To feed the service token to the container, use the INFISICAL_TOKEN environment variable as shown below.-- ```bash- docker run --env INFISICAL_TOKEN=[token] [DOCKER-IMAGE]...+ <Note>+ This method requires a Bash-compatible shell because it uses process substitution.+ </Note>++ ### Configure machine identity access++ Create a machine identity with permission to read the required secrets, configure it with [Universal Auth](/documentation/platform/identities/universal-auth), and copy its **Client ID** and **Client Secret**. Then copy the **Project ID** from **Project Settings**.++ Store these values in your automation platform's secret store rather than in source control.++ ### Authenticate with the CLI++ Exchange the machine identity credentials for a short-lived access token using the commands for your Infisical deployment:++ <CodeGroup>+ ```bash Infisical Cloud US+ export INFISICAL_TOKEN=$(infisical login \+ --method=universal-auth \+ --client-id=<client-id> \+ --client-secret=<client-secret> \+ --plain \+ --silent)```- </Step>- </Steps>+ ```bash EU Cloud or self-hosted+ # Use https://eu.infisical.com for EU Cloud or your self-hosted instance URL+ export INFISICAL_DOMAIN=<your-infisical-domain>++ export INFISICAL_TOKEN=$(infisical login \+ --method=universal-auth \+ --client-id=<client-id> \+ --client-secret=<client-secret> \+ --plain \+ --silent)+ ```+ </CodeGroup>++ ### Run your container++ Identify the project explicitly when exporting secrets, then pass them to the container:++ ```bash+ docker run --rm \+ --env-file <(infisical export --projectId=<project-id> --env=dev --format=dotenv) \+ orders-service+ ```++ Replace `<project-id>` with your project ID and `orders-service` with the image you want to run.++ <Warning>+ Docker's `--env-file` option doesn't support multiline secret values. Use the startup method if your application requires multiline secrets.+ </Warning>++ <Check>+ Your automation can now authenticate without a user session and inject secrets into the container.+ </Check></Tab></Tabs>++## Use with Docker Compose++If you [fetch secrets at startup](#fetch-at-startup), you can use [Docker Compose](https://docs.docker.com/compose/) to build and run one or more configured service images.++[Configure each image](/integrations/platforms/docker#update-your-dockerfile) to start through `infisical run`, then configure your Compose file for your Infisical deployment:++<CodeGroup>+ ```yaml Infisical Cloud US+ services:+ orders-service:+ build: .+ environment:+ INFISICAL_TOKEN: ${INFISICAL_TOKEN}+ ```++ ```yaml EU Cloud or self-hosted+ services:+ orders-service:+ build: .+ environment:+ INFISICAL_TOKEN: ${INFISICAL_TOKEN}+ INFISICAL_DOMAIN: ${INFISICAL_DOMAIN}+ ```+</CodeGroup>++Authenticate the machine identity in the same shell, then start the services using the commands for your Infisical deployment:++<CodeGroup>+ ```bash Infisical Cloud US+ export INFISICAL_TOKEN=$(infisical login \+ --method=universal-auth \+ --client-id=<client-id> \+ --client-secret=<client-secret> \+ --plain \+ --silent)++ docker compose up --build+ ```++ ```bash EU Cloud or self-hosted+ # Use https://eu.infisical.com for EU Cloud or your self-hosted instance URL+ export INFISICAL_DOMAIN=<your-infisical-domain>++ export INFISICAL_TOKEN=$(infisical login \+ --method=universal-auth \+ --client-id=<client-id> \+ --client-secret=<client-secret> \+ --plain \+ --silent)++ docker compose up --build+ ```+</CodeGroup>++<Note>+ If your self-hosted Infisical instance is running locally on the Docker host, don't set `INFISICAL_DOMAIN` to a `localhost` URL, since this will point to the container itself.++ Instead, set it to a `host.docker.internal` URL, [which points to the container's host domain](https://docs.docker.com/desktop/features/networking/networking-how-tos/#connect-a-container-to-a-service-on-the-host).+</Note>++### Use different permissions for each service++If multiple services need different access permissions, create a [machine identity](/documentation/platform/identities/machine-identities) for each permission set and pass each access token through a separate variable.++ Map each service to the access token for its machine identity:++<CodeGroup>+ ```yaml Infisical Cloud US+ services:+ web:+ build: ./web+ environment:+ INFISICAL_TOKEN: ${INFISICAL_TOKEN_WEB}++ api:+ build: ./api+ environment:+ INFISICAL_TOKEN: ${INFISICAL_TOKEN_API}+ ```++ ```yaml EU Cloud or self-hosted+ services:+ web:+ build: ./web+ environment:+ INFISICAL_TOKEN: ${INFISICAL_TOKEN_WEB}+ INFISICAL_DOMAIN: ${INFISICAL_DOMAIN}++ api:+ build: ./api+ environment:+ INFISICAL_TOKEN: ${INFISICAL_TOKEN_API}+ INFISICAL_DOMAIN: ${INFISICAL_DOMAIN}+ ```+</CodeGroup>++Authenticate each identity before starting the services:++<CodeGroup>+ ```bash Infisical Cloud US+ export INFISICAL_TOKEN_WEB=$(infisical login \+ --method=universal-auth \+ --client-id=<web-client-id> \+ --client-secret=<web-client-secret> \+ --plain \+ --silent)++ export INFISICAL_TOKEN_API=$(infisical login \+ --method=universal-auth \+ --client-id=<api-client-id> \+ --client-secret=<api-client-secret> \+ --plain \+ --silent)++ docker compose up --build+ ```++ ```bash EU Cloud or self-hosted+ # Use https://eu.infisical.com for EU Cloud or your self-hosted instance URL+ export INFISICAL_DOMAIN=<your-infisical-domain>++ export INFISICAL_TOKEN_WEB=$(infisical login \+ --method=universal-auth \+ --client-id=<web-client-id> \+ --client-secret=<web-client-secret> \+ --plain \+ --silent)++ export INFISICAL_TOKEN_API=$(infisical login \+ --method=universal-auth \+ --client-id=<api-client-id> \+ --client-secret=<api-client-secret> \+ --plain \+ --silent)++ docker compose up --build+ ```+</CodeGroup>++## Next steps++<CardGroup cols={2}>+ <Card title="Core Concepts" icon="book" href="/documentation/platform/secrets-mgmt/concepts/secrets-mgmt">+ Understand how projects, environments, folders, and secrets fit together.+ </Card>+ <Card title="Secrets Delivery" icon="truck-fast" href="/documentation/platform/secrets-mgmt/concepts/secrets-delivery">+ Explore other ways to deliver secrets to applications and infrastructure.+ </Card>+ <Card title="Machine Identities" icon="robot" href="/documentation/platform/identities/machine-identities">+ Configure workload authentication and access controls.+ </Card>+ <Card title="Infisical Run" icon="terminal" href="/cli/commands/run">+ Review all options for injecting secrets into an application process.+ </Card>+</CardGroup>diff --git a/docs/documentation/platform/secrets-mgmt/quick-starts/assets/key-value-fields.png b/docs/snippets/documentation/platform/secrets-mgmt/assets/key-value-fields.pngsimilarity index 100%rename from docs/documentation/platform/secrets-mgmt/quick-starts/assets/key-value-fields.pngrename to docs/snippets/documentation/platform/secrets-mgmt/assets/key-value-fields.pngdiff --git a/docs/documentation/platform/secrets-mgmt/quick-starts/assets/new-project.png b/docs/snippets/documentation/platform/secrets-mgmt/assets/new-project.pngsimilarity index 100%rename from docs/documentation/platform/secrets-mgmt/quick-starts/assets/new-project.pngrename to docs/snippets/documentation/platform/secrets-mgmt/assets/new-project.pngdiff --git a/docs/documentation/platform/secrets-mgmt/quick-starts/assets/review-secrets.png b/docs/snippets/documentation/platform/secrets-mgmt/assets/review-secrets.pngsimilarity index 100%rename from docs/documentation/platform/secrets-mgmt/quick-starts/assets/review-secrets.pngrename to docs/snippets/documentation/platform/secrets-mgmt/assets/review-secrets.pngdiff --git a/docs/snippets/documentation/platform/secrets-mgmt/configure-project.mdx b/docs/snippets/documentation/platform/secrets-mgmt/configure-project.mdxnew file mode 100644index 0000000000..d65623ebb5--- /dev/null+++ b/docs/snippets/documentation/platform/secrets-mgmt/configure-project.mdx@@ -0,0 +1,78 @@+## Step 1: Configure in Infisical++### Create a project++In Infisical, a [project](/documentation/platform/secrets-mgmt/project) holds all secrets for one application or service. To create a project:++<Steps>+ <Step>+ Log in to [Infisical](https://app.infisical.com).+ </Step>+ <Step>+ Select **Secrets Management** > **+ Add New Project**.+ </Step>+ <Step>+ In the **Project Name** field, enter a name for the project (e.g., `orders-service`).+ </Step>+ <Step>+ Select **Create Project**.+ </Step>+</Steps>++This opens your new project in the **Development** environment:++<Frame>+ +</Frame>++<Note>+ Within a project, secrets are organized across [environments](/documentation/platform/secrets-mgmt/project#project-environments). Every new project starts with three environments: **Development**, **Staging**, and **Production**.+</Note>++### Add your secrets++You have two options for adding secrets to your project:++<Tabs>+ <Tab title="Create secrets manually">+ To create a new secret from scratch:++ <Steps>+ <Step>+ Select **+ Add a New Secret**.+ </Step>+ <Step>+ In the **Key** and **Value** fields, enter a key-value pair. For example:++ <Frame>+ + </Frame>+ </Step>+ <Step>+ Select **Create Secret**.+ </Step>+ <Step>+ Repeat these steps for each key-value pair you want to add.+ </Step>+ </Steps>+ </Tab>+ <Tab title="Import secrets from an existing file">+ To import secrets from an existing file:++ <Steps>+ <Step>+ Drag and drop the file containing your secrets (or enter the file's contents manually by selecting **Paste Secrets**).+ </Step>+ <Step>+ Review the discovered secrets. For example:++ <Frame>+ + </Frame>+ </Step>+ <Step>+ Select **Upload Secrets**.+ </Step>+ </Steps>+ </Tab>+</Tabs>