DevOps Manual Set up - Set 2 Flashcards

1
Q

What are the differences between virtual machines and docker?

A

VMs emulate complete OS environments, consuming more resources but providing stronger isolation. Docker uses lightweight containers, sharing the host OS for efficiency, portability, and rapid deployment with slightly less isolation.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is a container?

A

It’s a lightweight package encapsulating an application and its environment, ensuring consistent execution across systems.

It isolates software, providing resource efficiency compared to virtual machines.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is a Docker image?

A

It’s a blueprint containing the instructions for creating a docker container. It contains the application’s code, runtime environment, dependencies, libraries, tools, configurations, and settings.

  • It’s a read-only template
  • It’s used to create consistent and isolated containers for applications.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Describe the docker architecture

A

Docker’s client-server architecture comprises the Docker client communicating with the Docker daemon. The daemon manages containers, using images from registries. Docker Compose defines multi-container apps, with Swarm and Kubernetes offering orchestration.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is Docker Compose?

A

It’s a tool that orchestrates multi-container Docker applications through a YAML configuration (config) file, defining and managing their execution efficiently.

It manages services, networks, volumes, and facilitates the development workflow, especially in microservices architectures.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is the Docker Client?

A

The Docker client is the primary user interface for Docker, providing a command-line interface (CLI) to interact with the Docker daemon. It sends commands via the Docker API, supports remote interactions, and can be customized and extended.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is the Docker Daemon?

A

The Docker daemon (dockerd) is Docker’s core process, managing container lifecycles. Users interface via the CLI or API, while the daemon handles tasks like communication with registries, networking, storage, security, and monitoring of containers.

This API is what the Docker CLI interacts with, but other tools can also use this API to communicate with the daemon.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is a docker Registry?

A

It’s a storage system for Docker images, facilitating storage, sharing and distribution. Docker Hub is the default public registry, but private registries exist for controlled storage.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is a container image builder technology?

A

It facilitates the creation of container images from application code and dependencies, often without needing manual Dockerfile management or a Docker daemon.

Examples: Dockerfile for Docker, Buildah, Jib (Java), and Podman - each streamlining container image creation differently

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is Jib?

A

Jib is a tool for creating container images for Java apps without a Dockerfile or Docker daemon. It offers reproducible builds, optimized layering, and integrates with Maven and Gradle, ensuring easy and consistent containerization.

Container Image Builder Technology

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Top 10 most used docker commands:

A
  • docker pull: Fetches an image from a registry.
  • docker images: Displays a list of downloaded images.
  • docker build: Builds a Docker image from a Dockerfile.
  • docker run: Creates and starts a new container based on an image.
  • docker ps: Lists all running containers.
  • docker stop: Halts a running container.
  • docker exec: Executes a command inside a running container.
  • docker rm: Removes one or more containers.
  • docker-compose: Manages multi-container applications using a YAML file.
  • docker logs: Displays logs from a container.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What are the advantages of Jib?

A
  • No Docker Daemon Required: Jib builds container images without relying on Docker, streamlining the build process especially in CI/CD environments.
  • Reproducible Builds: Jib guarantees consistent container images for the same source code, ensuring traceability and reliability.
  • Optimized Layering: Jib smartly layers Java applications, improving Docker’s caching mechanism for faster subsequent builds.
  • Easy Integration: With plugins for Maven and Gradle, Jib effortlessly integrates into existing Java build processes.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What are the steps to containerize a Spring Boot application without Jib?

A
  • Create a Dockerfile in the root directory with a Java base image.
    – Dockerfile content anticipates the name of the JAR file to be generated by the Maven build process.
  • Build the application (mvn package).
    mvn clean package
    – This will generate the your-spring-boot-app.jar in the target directory of your Spring Boot project.
  • Build Docker image (docker build).
    docker build -t my-spring-boot-app:v1 .
    – This command creates a Docker image tagged as my-spring-boot-app:latest.
  • Run container locally (docker run):
    docker run -p 8080:8080 my-spring-boot-app:v1
    – Starts a container based on the my-spring-boot-app:latest image, mapping port 8080 of the container to port 8080 on your local machine.
  • Login & Push to Docker registry (docker push):
    docker login
    docker push my-username/my-spring-boot-app:v1

my-spring-boot-app:v1 Is just an example name for the app.:v1 is a version specific tag to identify the image.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

While using Jib in a Java project, when you do NOT need a Docker daemon?

A

When building images. However, to run containers from those images, a container runtime (e.g., Docker daemon) or another platform/method is required.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Assuming Jib has been properly configured, what will this command do:

mvn clean package jib:build

A
  • mvn clean: removes previous build outputs (artifacts).
  • package:
    – compiles Java code (from .java to .class bytecode files)
    – tests (run unit tests)
    – packages code (.class and other resources to JAR)
  • jib:build: containerize the application and push the Docker image to a specified registry.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Explain the general steps to set up a connection between a containerized Spring Boot application and a database, both running as Docker containers.

A

1) Define a shared network for inter-container communication.
- In your docker-compose.yml file, place both apps on the same network, inside the services section.

2) Configure the database container with environment variables for credentials and database details.
- Inside docker-compose.yml file, define environment variables under the environment key

3) Set the Spring Boot application’s data source URL, using the database container’s service name as the host.
- In your application.properties or application.yml file, configure the database connection properties (such as database URL, username, password, etc.).

4) Ensure the application container depends on the database container using the depends_on directive.
- In your docker-compose.yml file, use the depends_on directive to ensure the application starts after the database container

17
Q

On Docker, how would you:

1) display a list of all the networks

2) view detailed information about a network

3) remove a specific network

A

1) docker network ls

2) docker network inspect [network_name]

3) docker network rm [network_name]

18
Q

On Docker, how would you:

1) list all containers

2) list all containers, including stopped ones

3) log messages related to a specific container

2) stop a running container

3) remove a specific container

A

1) docker container ls / docker ps

2) docker container ls -a / docker ps -a

3) docker logs [container-name] / [container-id]

4) docker container stop [container-name] / [container-id]

5) docker container rm [container-name] / [container-id]

19
Q

Describe the sequential process of transitioning from a Docker image to the creation of a container.

“…isolated, runnable instance…”

A

Images encapsulate software blueprints and are used to instantiate containers. When a container is created from an image, Docker utilizes the image’s blueprint to set up an isolated, runnable instance, providing a consistent execution environment.