# Ensure that Docker's secret management commands are used for managing secrets in a swarm cluster

- Source: https://support.icompaas.com/support/solutions/articles/62000234378-ensure-that-docker-s-secret-management-commands-are-used-for-managing-secrets-in-a-swarm-cluster
- Section: [Solutions](https://support.icompaas.com/support/solutions) › [CIS Docker Benchmark v1.7.0](https://support.icompaas.com/support/solutions/62000112687) › [CIS Docker Benchmark](https://support.icompaas.com/support/solutions/folders/62000169241)
- Last updated: 2026-05-29
- Publisher: iCompaas, Inc. (https://www.icompaas.com)

**Profile Applicability:**

-   **Level 1**  
    

**Description:**

Docker's secret management system ensures that sensitive data like passwords and API keys are handled securely within a swarm cluster. It allows secrets to be created, stored, and accessed securely, ensuring that secrets are never exposed in plain text within containers.  

**Rationale:**

Managing secrets directly through Docker’s secret management system provides a more secure and auditable way to handle sensitive data, preventing it from being exposed in Dockerfiles or environment variables.  

**Impact:**

Pros:  

-   Enhances security by securely storing secrets.  
    
-   Reduces the risk of secrets being accidentally exposed or leaked.  
    

Cons:  

-   Requires configuration and management of secrets within the Docker environment.  
    

**Default Value:**

By default, Docker does not use secret management. Secrets must be created and managed manually.  

**Pre-requisites:**

-   Docker Swarm mode should be enabled.  
    
-   Administrative privileges to manage Docker secrets.  
    

**Remediation:**

**Test Plan:**

**Using AWS Console:**

1.  Navigate to the EC2 instance running Docker.  
    
2.  Ensure that Docker Swarm is initialized by running:  
    

docker info | grep Swarm

3.  Verify that Docker secrets are being used by listing available secrets:  
    

docker secret ls

**Using AWS CLI:**

1.  Connect to the EC2 instance where Docker is running.  
    
2.  Run the following command to check if Docker secrets are in use:  
    

docker secret ls

**Implementation Plan:**

**Using AWS Console:**

1.  Log in to the EC2 instance.
    
2.  Initialize Docker Swarm if not already done:
    

docker swarm init

3.  Create a Docker secret:
    

echo "my\_secret\_password" | docker secret create my\_secret\_password -

4.  Verify that the secret is listed:
    

docker secret ls

**Using AWS CLI:**

1.  Use SSM to create a Docker secret remotely:  
    

aws ssm send-command --document-name "AWS-RunShellScript" --targets "Key=instanceIds,Values=instance\_id" --parameters 'commands=\["echo \\"my\_secret\_password\\" | docker secret create my\_secret\_password -"\]'

**Backout Plan:**

**Using AWS Console:**

1.  Connect to the EC2 instance.  
    
2.  Remove the Docker secret:  
    

docker secret rm my\_secret\_password

**Using AWS CLI:**

1.  Use SSM to remove the Docker secret:  
    

aws ssm send-command --document-name "AWS-RunShellScript" --targets "Key=instanceIds,Values=instance\_id" --parameters 'commands=\["docker secret rm my\_secret\_password"\]'

**References:**

-   Docker Secret Management
    
-   [Docker Documentation  
    ](https://docs.docker.com/)

## Related compliance guidance

- [SOC 2 compliance: a practical implementation guide for cloud-native SaaS teams](https://support.icompaas.com/compliance/soc-2-trust-services-criteria): Configuration checks like this one are the technical half of a SOC 2 / ISO 27001 programme — the guide shows where they fit, what else an auditor expects, and how to evidence them.
- [ISO/IEC 27001:2022 compliance: a practical implementation guide](https://support.icompaas.com/compliance/iso-27001-2022): ISO 27001 Annex A.8 (technological controls) is where cloud hardening evidence lands; the guide shows how to run the ISMS around it.
