Exercise 2 PDF Information Flashcards
Problems with Mongo DB deployment?
- 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
What is containerization?
- 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
What is the docker engine composed of?
Docker Daemon (executes commands of Docker client)
Docker Client (communicates with the Docker Daemon)
REST API (for interaction with Docker Daemon remotely)
What is the docker daemon? Where does it gets its information from?
The docker client talks to the docker daemon, which does the heavy lifting of building, running, and distributing docker containers.
What does the Docker provide unified access to?
- linux container technology (cgroups, namespaces)
- various container implementations
What is a runtime (internet)
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
docker container process (low-level)
Dockerfile
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.
Docker registry (internet)
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.
Advantage of containers
- 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 does an image relate to layers?
- 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
Difference between a container and image
- 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
Docker Containers build flow
Explain the meaning of:
FROM node:alpine
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.
Explain the meaning of:
RUN mkdir -p /usr/src/server
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.
Docker run command
Explain the meaning of:
WORKDIR /usr/src/server
the WORKDIR instruction sets the working directory for the container, and all the subsequent instructions like ‘RUN’ will be executed relative to this directory.
Copy the package.json file which contains all the dependencies required for the application
Explain the meaning of:
COPY package.json /usr/src/server/