Exercise 2 PDF Information Flashcards

1
Q

Problems with Mongo DB deployment?

A
  • OS dependent. Different deployment procedure and requirements for different OS
  • not scalable: run on more laptops or VMs? not an ideal solution
  • not portable: running the same procedure from scratch on a new machine is a waste of time

-> Solution: containerization

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

What is containerization?

A
  • An OS-level virtualisation method for deploying and running distributed applications without launching an entire VM for each application.
  • Share the same OS kernel as the host
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is the docker engine composed of?

A

Docker Daemon (executes commands of Docker client)
Docker Client (communicates with the Docker Daemon)
REST API (for interaction with Docker Daemon remotely)

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

What is the docker daemon? Where does it gets its information from?

A

The docker client talks to the docker daemon, which does the heavy lifting of building, running, and distributing docker containers.

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

What does the Docker provide unified access to?

A
  • linux container technology (cgroups, namespaces)
  • various container implementations
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is a runtime (internet)

A

A runtime, in the context of containerization, is the software that is responsible for creating and managing the execution of containers. It provides the low-level functionality necessary to start, stop, and manage the container’s process, such as creating namespaces, cgroups, and network interfaces

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

docker container process (low-level)

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

Dockerfile

A

A Dockerfile is a script that contains a set of instructions that are used to build a Docker image. It is a plain text file that contains all the commands, in order, needed to build a specific version of an image.

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

Docker registry (internet)

A

A Docker registry is a service that stores and distributes Docker images. It is a central location where developers can upload and share their images, and from where users can download and run those images on their own systems.

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

Advantage of containers

A
  • packs your application in a container with all of your applications bins/libs and dependencies
  • makes it fully isolated from external environments regardless of where it is running
  • we can ship that container to anywhere (any other OS, to Docker Registry)

-> OS independent, scalable, portable

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

How does an image relate to layers?

A
  • a docker image is built up from a series of layers
  • each layer represents an instruction of the image’s Dockerfile
  • a new writable layer on top of the underlying layers often called “container layer” and is added when a new container is created
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Difference between a container and image

A
  • the major difference between a container and an image is the top writable layer
  • all new writes to the container are stored in this writeable layer
  • multiple containers can share access to the same underlying image and yet have their own data state
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Docker Containers build flow

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

Explain the meaning of:
FROM node:alpine

A

FROM node:alpine is a command used in a Dockerfile, which is used to build a Docker image. This command specifies that the base image for the new image being built should be the official Node.js image with the tag “alpine”. Alpine Linux is a lightweight Linux distribution that is often used as the base image for Docker images because it is small and has a minimal set of packages installed, which makes the resulting image smaller and more secure.

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

Explain the meaning of:
RUN mkdir -p /usr/src/server

A

Create a new directory named server in the /usr/src/ directory. This command is commonly used to create a directory where the application code will be stored in the container.

RUN mkdir -p /usr/src/server is a command used in a Dockerfile, which is used to build a Docker image. This command tells Docker to run the command mkdir -p /usr/src/server in the container, when the image is built.

mkdir is a command in Linux and Unix-like operating systems that creates a new directory.
-p option creates the parent directory if it doesn’t exist.
/usr/src/server is the path to the new directory that will be created.

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

Docker run command

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

Explain the meaning of:
WORKDIR /usr/src/server

A

the WORKDIR instruction sets the working directory for the container, and all the subsequent instructions like ‘RUN’ will be executed relative to this directory.

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

Copy the package.json file which contains all the dependencies required for the application

A

Explain the meaning of:
COPY package.json /usr/src/server/

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

This command will install all the dependencies listed in package.json

A

Explain the meaning of:
RUN npm install

20
Q

This command copies all files and directories from the build context (the directory where the Dockerfile is located) to the specified destination directory /usr/src/server inside the container file system.

A

COPY . /usr/scr/server

21
Q

Expose container port to the host machine

A

Explain the meaning of:
EXPOSE 3000

22
Q

A start command to run the application

A

Explain the meaning of:
CMD [“node”, “server.js”]

23
Q

What is the Docker HUB?

A
  • cloud based registry service
  • allows you to link code repositories, build your images, stores manually pushed images, and links to Docker Cloud so you can deploy images to your hosts
24
Q

What does the Docker run command do?

A

Docker –> tells the OS that you are using the docker program
run –> a subcommand that creates & runs a docker container
‘hello-world’ –> tells the docker which image to load into the container

25
Q

What are tags used for with Images?

A

A tag is a subcommand that tags an image s that different versions of the image can identified.

26
Q

Build an image from the Dockerfile in the directory and tag the image

A

Explain the meaning of:
docker build -t <image-name>:<tag> <Directory></Directory></tag></image-name>

27
Q

lists all images that are locally stored with the Docker engine

A

Explain the meaning of:
docker images

28
Q

List running containers

A

docker ps

29
Q

stop a running container

A

Explain the meaning of:
docker stop <container-id></container-id>

30
Q

remove a running container

A

Explain the meaning of:
docker rm <container-id></container-id>

31
Q

delete an image from the local image store.

The local image store is a repository where Docker images are stored on a local machine.

A

Explain the meaning of:
docker rmi <image-name></image-name>

32
Q

When a container exits, by default, it is not removed from the host, it remains in the stopped state. This means that the container still exists and takes up disk space. If you want to remove the container after it exits, you can use the “” option when starting the container.

A

–rm

33
Q

command to start an interactive container in a terminal. This allows you to interact with the container by typing commands and receiving output.

A

-it

34
Q

name the container

A

–name <nam></nam>

35
Q

expose port 5000 externally and map to port 80

A

-p 5000:80

36
Q

mount a host directory ~/dev as a volume inside a container at the path /code. This allows the files and directories in the host’s ~/dev to be accessed and modified by the processes running inside the container. This option is useful for sharing data between the host and container, or for persisting data when the container is deleted.

A

-v~/dev:/code

37
Q

the image from which the container is instantiated

A

image:tag

38
Q

The container will start and give you an interactive shell prompt where you can run commands inside the container.

A

/bin/sh

39
Q

What is docker-compose

A
  • compose is a tool for defining and running multi-container docker applications
40
Q

docker-compose build

A

build all the images

41
Q

docker-compose build <image-name></image-name>

A

build only the selected image

42
Q

docker login
docker login <registry-host></registry-host>

A

log in to a registry (the docker hub by default)

43
Q

docker-compose push

A

push images to registry

44
Q

docker-compose up

A

used to start all containers

45
Q

docker-compose up -d

A

to start all containers in the background

46
Q

docker-compose stop

A

stop the containers

47
Q

docker-compose kill

A

kill the containers