Run the StrongDM Client on Docker
Two options are available to run the StrongDM client on Docker:
Deploy our premade Docker Service Client Container, which includes the StrongDM client.
Install the StrongDM client on your existing Docker container.
Choosing the StrongDM Docker Service Client Container is an ideal option if you plan to use separate containers to run StrongDM in your cluster or Docker environment, or if you have yet to install any containers. Alternately, you may have containers with applications already installed or containers deployed in specific flavors of Linux. In such cases, adding StrongDM may be the best option.
The following guide provides instructions for both deployment options.
Deploy the StrongDM Docker Service Client Container
This section describes how to deploy a Docker container that comes with the StrongDM client preinstalled. There are two primary methods to add the StrongDM client container to your containerized deployment: you can run it as a service so that it is persistently available or deploy it on an as-needed basis.
About
The StrongDM Docker Service Client Container is a lightweight Ubuntu 22.04-based Docker image with the StrongDM client binary pre-installed. This image can be obtained from ECR by running the following Docker command:
docker pull public.ecr.aws/strongdm/clientNote that you may obtain the same link from the Admin UI's Downloads & Install page.
Authentication
A service account token needs to be added as an environment variable to the container. This token acts as your container's login credentials, which allows you to restrict access at any time from the Admin UI. If you have not already set up a service token, please see the Service Accounts instructions.
For the service account to work effectively, port overrides and auto-connect should both be enabled for your organization. Enabling these settings ensures a consistent login procedure for your container during runtime. As these changes will affect your entire organization, please review our documentation.
Persistent deployment
For this example, the persistent container maps a container port (13307) to the same port on the host machine.
Validate the container connected successfully with sdm status from the container.
The output may be similar to the following:
By running sdm status we see that the published port, in this case 13307, refers to the datasource StrongDM-datasource1-sfo2-world.
At this point, the container should be operational and ready to accept connections on the exposed port.
Database connections
Use your normal database client to connect to the host port that is mapped to the container. The following output is trimmed for readability.
Check what containers are running:
Locate the appropriate container ID.
Check the specific container's status.
Something similar to the following returns.
Check the https://app.gitbook.com/s/HaY8OFbXUreWEF61MhKm/connect/databases page if you are unsure of the proper connection settings for your database client.
SSH connections
Similar to the DB connection, if the SSH connection port is exposed to the host machine, any SSH attempts to that port get routed through the StrongDM client binary in the container. The following output is trimmed for readability.
Check what containers are running.
Locate the appropriate container ID.
Check the specific container's status.
Something similar to the following returns.
Make an SSH attempt to the port.
Verify you are routed through the StrongDM client binary.
Run as a service
To simplify the deployment process, we recommend deploying the StrongDM Docker Service Client Container as a service. Below is a basic StrongDM service file to be used as an example. This file can be added to your systemd folder structure, such as /lib/systemd/system/strongdm.service.
With the service file added, it can now be used with normal systemctl commands or the equivalent in your distro.
To enable the service so that it is started automatically when the system boots up, use the enable command.
Per-job deployment
The StrongDM Docker Service Client Container lifecycle can also be automated to run on demand. When taking this approach, be mindful of loading times as they may vary depending on the environment. The following examples show how to add availability validations into a bash script.
Start the container
In this example, the Docker client binary is invoked to start the StrongDM Docker Service Client Container. Running the StrongDM Docker Service Client Container starts the StrongDM client binary automatically, but not instantly. Using the until command is one way to check that the StrongDM client binary is available. If it is not, then the script sleeps for one second and tries again until successful.
Wait for datasources to connect
This same until logic can be added to check if a datasource is ready. In the following example, the psql -l invocation checks if the connection is available without fully connecting. Once it returns successfully, you can run normal database operations.
Wait for the SSH server
Similarly, any SSH connections may have a slight delay between the StrongDM client binary being ready and the connection status becoming available.
Stop the StrongDM Docker Service Client Container
Perform docker stop on the StrongDM Docker Service Client Container before ending the script to terminate it gracefully.
Put it all together
Avoid loops
To make your script a bit more robust, the number of connection attempts can be limited to prevent infinite loops. To do so, replace the relevant section in the script above with the following loop:
Deploy the StrongDM Client on Your Existing Docker Container
Using StrongDM to control access management for your container deployments is similar to using your local StrongDM client binary. You can deploy StrongDM in fully automated workflows, ETL, jobs, and more. This section describes adding the StrongDM client to an existing Docker container.
Dockerfile StrongDM layer
To help you get started, the following examples demonstrate how to add the StrongDM client binary as a single layer to a Dockerfile.
Ubuntu Dockerfile script
CentOS Dockerfile script
Entrypoint script
Alpine Dockerfile StrongDM layer
The following example demonstrates how to add StrongDM as a single layer to an Alpine Dockerfile.
Alpine Dockerfile script
Alpine entrypoint script
Build the image
Create a new directory containing the entrypoint script (start.sh) and Dockerfile of choice.
Run
chmod +x start.shto make the start.sh script executable.Run
docker build -t sdmimage .to build the image.Check for the image with the following command:
Something similar to the following returns.
Authenticate the StrongDM client
When using StrongDM in an automated fashion, access is validated and managed using a service account.
For the automated service to work effectively, port overrides and auto-connect should both be enabled. These settings ensure a consistent login procedure for your container during runtime. They affect your entire organization, so please review our documentation and contact your StrongDM administrator before making any changes. Any customization of local ports used by resources stops auto-connection to those resources by service accounts.
The StrongDM client binary looks for the environment variable SDM_ADMIN_TOKEN when authenticating requests. This variable can be added to the environment in a few different ways. If you followed the instructions in the previous section, you can start the image you just created and add the variable during runtime with the -e flag. For example, use docker run -d -e SDM_ADMIN_TOKEN=StrongDM_token sdmimage.
Add tokens in a Dockerfile or start script
To simplify the runtime command, the service token can also be added to either the Dockerfile or start.sh script. Either of these options requires building a new Docker image once you have made this change.
To add a service token to a Dockerfile, use
ENV SDM_ADMIN_TOKEN=StrongDM_token.To add a service token to a start script, use
export SDM_ADMIN_TOKEN=StrongDM_token.
Last updated
Was this helpful?

