Docker Compose Mastery Quiz Quiz

  1. Compose File Version

    Which top-level key in a Docker Compose file defines the version of the Compose file format being used?

    1. services
    2. version
    3. compose
    4. dockerfile
    5. build
  2. Service Definition

    Within a Docker Compose file, what top-level key is used to define the individual services that make up your application?

    1. containers
    2. build
    3. images
    4. services
    5. networks
  3. Build Context

    If you want Docker Compose to build an image from a Dockerfile in the current directory for a service, how do you configure the 'build' context?

    1. build: .
    2. build: ./Dockerfile
    3. build: dockerfile
    4. build: current
    5. build: images
  4. Environment Variables

    How can you define environment variables for a service in a Docker Compose file?

    1. with the 'environments' key
    2. with the 'env' key
    3. with the 'variables' key
    4. with the 'environment' key
    5. using the docker CLI
  5. Port Mapping

    What is the correct syntax in a Docker Compose file to map port 8080 on the host to port 80 on the container?

    1. ports: [80:8080]
    2. ports: 8080:80
    3. expose: [8080:80]
    4. ports: [8080:80/tcp]
    5. ports: 80-8080
  6. Linking Services (Deprecated)

    Which deprecated key was previously used to establish communication links between services in Docker Compose?

    1. depends_on
    2. networks
    3. links
    4. expose
    5. volumes
  7. Data Persistence

    What mechanism does Docker Compose utilize to persist data between container restarts?

    1. caches
    2. networks
    3. volumes
    4. bind mounts
    5. images
  8. Depends On

    How do you ensure that one service starts only after another service has started in Docker Compose?

    1. using the 'depends_on' key
    2. using the 'links' key
    3. using the 'needs' key
    4. using the 'order' key
    5. with a start up script
  9. Scaling Services

    Which Docker Compose command is used to scale a service to a specified number of replicas?

    1. docker-compose up --scale
    2. docker-compose scale
    3. docker-compose replicas
    4. docker scale
    5. docker-compose run
  10. Network Creation

    How do you create a custom network for your services in Docker Compose?

    1. using the 'networks' key at the top level of the Compose file
    2. using the 'network' key at the service level
    3. using the docker network create command
    4. using the 'links' key
    5. it is not possible in compose