Docker Compose Flashcards

You may prefer our related Brainscape-certified flashcards:
1
Q

Docker Compose Basics

A
  • Markdown tool to specify Docker configurations as code
  • Procedural
  • Declarative
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Production System Considerations

A
  • Multiple Systems
  • Microservices
  • Third-party dependencies
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Procedural

A
  • Series of ordered steps
  • Based on assumptions about the previous step
  • Easy to introduce errors
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Declarative

A
  • Specify end results
  • System will determine which steps to execute
  • Produces the same result each time
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Main Benefits of Docker Compose

A
  • Version control
  • Self-documenting
  • Easy management
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Designed For

A
  • Local development
  • Staging server
  • Continuous integration testing environment
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Not Designed For

A
  • Distributed systems
  • Complex production environments
  • No autoscaling
  • Use orchestration tools like Docker Swarm or Kubernetes in production
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Docker Compose Configuration

A
  • Create a file “docker-compose.yaml”
  • Version: specifies which version of Docker Compose to use
  • Services: specifies which containers are required (specify a path to the corresponding Docker build file or image)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Start all services defined in the Docker Compose file

A
  • “docker-compose up”
  • Pass in a service name to any command to only apply it to that service
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Stop all containers

A
  • “docker-compose down”
  • Deletes all containers and images and removes all artifacts
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Save battery or free memory

A
  • “docker-compose stop”
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Stop and restart all containers

A
  • “docker-compose restart”
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Environment Variables

A
  • Accessible inside a running Docker container
  • Specify runtime environment
  • Use env files if necessary (pass in env file path)
  • Including an env variable name without a value will pass in the value from the host server
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Build Arguments

A
  • Accessible only at build times
  • Build tool versions
  • Cloud platform configuration
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Target Volume

A
  • File directory path inside a container where the volume data lives
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Source Volume

A
  • File directory path on the host machine outside a container where the volume data lives
17
Q

Volume Access Modes

A
  • rw: read-write by default
  • ro: read-only
18
Q

Mounting Volume Syntax

A
  • <source></source>:<TARGET>:<MODE></MODE></TARGET>
19
Q

Named Volumes

A
  • Running “docker-compose up” or “docker-compose restart” will automatically copy old volume data to the new container
  • Running “docker-compose down –volumes” will automatically delete named volumes
  • Without named volumes you can run out of memory
20
Q

Exposing Ports

A
  • Map the ports for all containers in the Docker Compose file
21
Q

Enforcing Container Start-Up Order

A
  • Add a “depends_on” object under a service definition in the Docker Compose file
  • Only guarantees that dependent containers have been started, not that they are healthy and running
22
Q

Advantages of a Single Compose File

A
  • Shared containers
  • Easier integration testing
  • Conceptually one system
23
Q

Named Subsets of Services

A
  • List one or more profile names under the profile keyword for a service
  • A container with no profiles specified is included by default
  • Docker Compose commands will only apply to a service if its profile is explicitly enabled
  • Add “–profile <NAME>" to enable a non-default profile</NAME>
24
Q

Multiple Compose Files

A
  • Distinct desired behaviors that do not coincide
  • Different environments
  • By default, Docker Compose will read docker-compose.yaml and docker-compose.override.yaml
  • Docker Compose will merge the two files
25
Q

Merge Rules for Compose Files

A
  • Array fields: original + override
  • Single-value fields: preference to override
  • Override can be a partial or incomplete configuration
26
Q

Run Docker Compose Override

A
  • “docker-compose -f <PRIMARY> -f <OVERRIDE> <CMD>"</CMD></OVERRIDE></PRIMARY>
27
Q

Example Environment Variables

A
  • Image tags
  • Software versions
  • Ports
28
Q

Accessing Environment Variables

A
  • Use the syntax “${NAME}”
29
Q

Environment Variable Defaults

A
  • Empty string (automatic)
  • Inline in docker-compose configuration
  • In .env file
  • Throw error if missing (no default)
  • The host env variable in the shell will always supersede the default
30
Q

Pass in a .env file

A
  • ”–env-file <PATH>"</PATH>