Problems with Mongo DB deployment?
-> Solution: containerization
What is containerization?
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?
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
-> OS independent, scalable, portable
How does an image relate to layers?
Difference between a container and image
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/
This command will install all the dependencies listed in package.json
Explain the meaning of:
RUN npm install
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.
COPY . /usr/scr/server
Expose container port to the host machine
Explain the meaning of:
EXPOSE 3000
A start command to run the application
Explain the meaning of:
CMD [“node”, “server.js”]
What is the Docker HUB?
What does the Docker run command do?
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