Bird
Raised Fist0
Microservicessystem_design~5 mins

Docker basics review in Microservices - Cheat Sheet & Quick Revision

Choose your learning style10 modes available

Start learning this pattern below

Jump into concepts and practice - no test required

or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Recall & Review
beginner
What is Docker in simple terms?
Docker is a tool that lets you package an application and all its parts into a container. This container can run anywhere, making it easy to move and share apps.
Click to reveal answer
beginner
What is a Docker container?
A Docker container is like a small, lightweight box that holds your app and everything it needs to run. It keeps your app isolated from other apps on the same computer.
Click to reveal answer
intermediate
What is the difference between a Docker image and a Docker container?
A Docker image is a blueprint or recipe for creating containers. A container is a running instance made from that image.
Click to reveal answer
intermediate
Why is Docker useful in microservices architecture?
Docker helps by packaging each microservice in its own container. This makes it easy to develop, test, and deploy services independently without conflicts.
Click to reveal answer
beginner
What is a Dockerfile and why do we use it?
A Dockerfile is a simple text file with instructions to build a Docker image. It tells Docker how to set up the app environment step-by-step.
Click to reveal answer
What does a Docker container include?
AThe app and all its dependencies
BOnly the app code
COnly the operating system
DOnly the network settings
Which file is used to build a Docker image?
AREADME.md
Bdocker-compose.yml
Cconfig.json
DDockerfile
How does Docker help with microservices?
ABy isolating each service in its own container
BBy combining all services into one big app
CBy replacing the need for servers
DBy removing the need for code
What is the main difference between a Docker image and a container?
AImage runs the app; container stores the app
BImage is a blueprint; container is a running instance
CImage is bigger than container
DThere is no difference
Which command starts a Docker container?
Adocker build
Bdocker stop
Cdocker run
Ddocker pull
Explain how Docker containers help in deploying microservices.
Think about how each microservice runs separately and can be managed on its own.
You got /4 concepts.
    Describe the role of a Dockerfile in creating Docker images.
    Imagine writing a recipe for baking a cake.
    You got /4 concepts.

      Practice

      (1/5)
      1. What is the main purpose of Docker in microservices architecture?
      easy
      A. To replace the need for servers entirely
      B. To write application code faster
      C. To package applications with all dependencies for consistent deployment
      D. To monitor network traffic between services

      Solution

      1. Step 1: Understand Docker's role

        Docker packages applications with their dependencies to ensure they run the same everywhere.
      2. Step 2: Compare options

        Only To package applications with all dependencies for consistent deployment describes packaging apps with dependencies; others describe unrelated tasks.
      3. Final Answer:

        To package applications with all dependencies for consistent deployment -> Option C
      4. Quick Check:

        Docker packages apps = B [OK]
      Hint: Docker bundles apps and dependencies for consistent runs [OK]
      Common Mistakes:
      • Thinking Docker replaces servers
      • Confusing Docker with coding tools
      • Assuming Docker monitors network
      2. Which Docker command is used to create a new image from a Dockerfile?
      easy
      A. docker run
      B. docker start
      C. docker push
      D. docker build

      Solution

      1. Step 1: Identify command purpose

        docker build creates an image from a Dockerfile.
      2. Step 2: Eliminate other commands

        docker run starts containers, docker start restarts stopped containers, docker push uploads images to a registry.
      3. Final Answer:

        docker build -> Option D
      4. Quick Check:

        Build = create image [OK]
      Hint: Build creates images; run starts containers [OK]
      Common Mistakes:
      • Using docker run to create images
      • Confusing docker start with build
      • Thinking docker push creates images
      3. Given this Docker command sequence, what happens?
      docker build -t myapp .
      docker run -d --name app1 myapp
      medium
      A. Builds an image named myapp and runs it detached as container app1
      B. Runs a container named myapp and builds app1 image
      C. Builds a container named myapp and runs it interactively
      D. Fails because -d and --name cannot be used together

      Solution

      1. Step 1: Analyze docker build command

        docker build -t myapp . creates an image tagged 'myapp' from current directory.
      2. Step 2: Analyze docker run command

        docker run -d --name app1 myapp runs container named 'app1' in detached mode from image 'myapp'.
      3. Final Answer:

        Builds an image named myapp and runs it detached as container app1 -> Option A
      4. Quick Check:

        Build image then run container detached = A [OK]
      Hint: Build tags image; run starts container with name and mode [OK]
      Common Mistakes:
      • Mixing image and container names
      • Thinking -d disables naming
      • Confusing build and run order
      4. Identify the error in this Docker command:
      docker run --name mycontainer -p 8080 myimage
      medium
      A. Port mapping syntax is incomplete
      B. Missing container name
      C. Image name is missing
      D. Cannot use -p with --name

      Solution

      1. Step 1: Check port mapping syntax

        -p 8080 is incomplete; it should specify host and container ports like -p 8080:80.
      2. Step 2: Verify other parts

        Container name and image name are present; no restriction on using -p with --name.
      3. Final Answer:

        Port mapping syntax is incomplete -> Option A
      4. Quick Check:

        Port mapping needs host:container format [OK]
      Hint: Port mapping needs host:container format [OK]
      Common Mistakes:
      • Omitting container port in -p
      • Assuming image name is missing
      • Thinking -p and --name conflict
      5. You want to deploy multiple microservices using Docker containers on one host. Which approach best ensures isolation and easy management?
      hard
      A. Run all microservices inside a single container
      B. Use separate containers for each microservice with individual Dockerfiles
      C. Install all microservices directly on the host OS without containers
      D. Use one container per microservice but share the same network and volumes without isolation

      Solution

      1. Step 1: Understand container isolation

        Each microservice should run in its own container for isolation and independent management.
      2. Step 2: Evaluate options

        Use separate containers for each microservice with individual Dockerfiles uses separate containers with individual Dockerfiles, enabling isolation and scalability. Run all microservices inside a single container mixes services, reducing isolation. Install all microservices directly on the host OS without containers lacks container benefits. Use one container per microservice but share the same network and volumes without isolation shares resources without isolation.
      3. Final Answer:

        Use separate containers for each microservice with individual Dockerfiles -> Option B
      4. Quick Check:

        Separate containers = isolation + management [OK]
      Hint: One container per microservice for isolation and scaling [OK]
      Common Mistakes:
      • Running all services in one container
      • Skipping containers and installing on host
      • Sharing networks and volumes without isolation