Fatskills
Practice. Master. Repeat.
Study Guide: Docker Docker Docker Compose Profiles Extensions
Source: https://www.fatskills.com/kubernetes/chapter/docker-docker-docker-compose-profiles-extensions

Docker Docker Docker Compose Profiles Extensions

By Fatskills Exam Guides Team — the exam nerds behind 28,500+ quizzes and 2.1M practice questions across 500+ global exams.

⏱️ ~2 min read

1. Core Command / Concept

Create and manage Docker profiles to customize the Docker environment. docker profile.

2. Step-by-Step

  1. Check if Docker is installed: docker --version
  2. Create a new profile: docker profile create myprofile
  3. List all profiles: docker profile ls
  4. Switch to the new profile: docker profile use myprofile
  5. ⚠️ Delete a profile: docker profile rm myprofile
  6. List all running containers: docker ps
  7. List all stopped containers: docker ps -a
  8. Clean up stopped containers: docker container prune

3. Real Commands with Examples


Example 1: Create a new profile for development

Purpose: Create a new profile for development with specific settings.
Command: docker profile create devprofile --env=DEBUG=1 --env=PORT=3000 Flags: --env sets environment variables.

Example 2: Create a new profile for production

Purpose: Create a new profile for production with specific settings.
Command: docker profile create prodprofile --env=NODE_ENV=production --env=PORT=80 Flags: --env sets environment variables.

Example 3: Create a new profile for testing

Purpose: Create a new profile for testing with specific settings.
Command: docker profile create testprofile --env=TEST=1 --env=PORT=3001 Flags: --env sets environment variables.

4. Common Errors


Error 1: Profile not found

Error message: Error: profile not found Why it happens: You tried to switch to a non-existent profile.
Fix: docker profile ls to list all available profiles.

Error 2: Profile already exists

Error message: Error: profile already exists Why it happens: You tried to create a profile with the same name as an existing one.
Fix: docker profile rm existingprofile to delete the existing profile.

Error 3: Profile not active

Error message: Error: profile not active Why it happens: You tried to switch to a profile that is not active.
Fix: docker profile use activeprofile to switch to an active profile.

5. Quick Checks


Scenario 1: Profile is active

Situation: You want to check if a profile is active.
Command: docker profile ls Correct response: The active profile is listed.

Scenario 2: Profile is not active

Situation: You want to check if a profile is not active.
Command: docker profile ls Correct response: The active profile is not listed.

Scenario 3: Profile is deleted

Situation: You want to check if a profile is deleted.
Command: docker profile ls Correct response: The deleted profile is not listed.

6. Last-Minute Reference

• Docker profiles are stored in ~/.docker/profiles/.
• Use docker profile create to create a new profile.
• Use docker profile use to switch to a profile.
• Use docker profile rm to delete a profile.
• Use docker profile ls to list all profiles.
• ⚠️ Be careful when deleting profiles, as it will delete all associated containers.
• ⚠️ Docker profiles are specific to the user who created them.
• Docker profiles are not compatible with Docker Compose.
• Use docker profile export to export a profile to a file.
• Use docker profile import to import a profile from a file.




ADVERTISEMENT