- what is Docker ?
Docker is a popular platform that simplifies the process of creating, deploying, and managing containers by providing a set of tools and a platform for containerization .
- what is Docker Engine ?
Docker Engine is the software responsible for creating and managing containers, providing a consistent and reliable platform for developing, shipping, and running applications. it consists of several parts :
- DOCKER DAEMON (dockerd): This is a persistent process that manages Docker objects, such as images, containers, networks, and volumes.
- DOCKER CLIENT (docker): This is the primary interface that users interact with to communicate with the Docker daemon.
- REST API: Docker Engine provides a RESTful API that allows external programs to communicate with the Docker daemon.
- COMMAND-LINE INTERFACE (CLI): The Docker CLI provides a set of commands that users can run in their terminal to interact with Docker Engine.
- CONTAINERD AND OTHER COMPONENTS: Docker Engine also includes other components like Containerd, which is responsible for container execution and supervision, and other libraries and dependencies necessary for its operation.
Here are some of the most used docker CLI commands:
- docker run: This command is used to create and start a new Docker container from a Docker image. It allows you to specify various options such as ports, volumes,environment variables, and more.
- docker build: This command is used to build a Docker image from a Dockerfile.
- docker pull: This command is used to pull (i.e., download) a Docker image from a Docker registry such as Docker Hub. If the image is not available locally, it will be downloaded from the registry.
- docker ps: This command is used to list all running Docker containers. By default, it only shows the running containers. You can use the -a option to show all containers,including the ones that are stopped.
- docker stop: This command is used to stop one or more running Docker containers. You can specify the containers either by their IDs or names.
- docker start: This command is used to start one or more stopped Docker containers.Similar to docker stop, you can specify the containers by their IDs or names.
- docker rm: This command is used to remove one or more Docker containers. You can specify the containers either by their IDs or names.
- docker exec: This command is used to execute a command inside a running Docker container. It allows you to run commands such as shell commands, scripts, etc.,inside the container.
- docker logs: This command is used to view the logs generated by a Docker container.You can use it to monitor the output of a containerized application in real-time.
- docker images: this command is used to list docker images you've created locally.
- docker rmi: this command is used to delete a docker image.
for more details and more docker CLI commands, go to "https://docs.docker.com/reference/cli/docker/" .
- what is image ?
An image is a template or blueprint for creating containers. it contains everything neede to run a specific application including the code, runtime, libraries,dependencies,and settings. images are immutable and read-only; once built, they cannot be modified .
- what is container ?
A container is a running instance of a Docker image. Containers are isolated environments that encapsulate an application and its dependencies, allowing it to run consistently across different environments. Containers are lightweight, portable, and can be started, stopped, and moved between different host systems with minimal overhead. Containers are ephemeral by default; changes made within a container are lost when the container is stopped unless persistent storage is configured.
- what is the difference between image and container ?
NATURE: An image is a static, immutable file that serves as a blueprint for containers, while a container is a running instance of an image. STATE: Images are read-only and immutable, while containers are writable and can store changes made during runtime (unless using techniques like Docker commit to create a new image from a container). LIFECYCLE: Images persist between runs and can be used to create multiple containers, while containers are transient and exist only while they are running. USAGE: Images are used to package and distribute applications, while containers are used to run and manage those applications in isolated environments.
- what is Dockerfile ?
A dockerfile is a text document that contains instructions for building a docker image. These instructions typically include commands for copying files into the image , installing dependencies, setting environment variables, and specifying the commands to run when the container is started.
here are some of the most commonly used commands in a dockerfile :
- FROM: syntax(FROM image:tag); command that specifies the base image from which you are building. it is the starting point of your dockerfile.
- RUN: syntax(RUN command); executes commands during the docker image built process, these commands typically install packages, update repositories, configure the environment, or perform other tasks necessary to set up the application environment within the image.
- COPY: syntax(COPY src dest); copies files or directories from the host machine into the container's filesystem.
- ADD: syntax(ADD src dest); to the same as COPY + supports URLs and can automatically unpack compressed files.
- WORKDIR: syntax(WORKDIR path); this sets the working directory for any RUN,CMD,ENTRYPOINT,COPY,and ADD instructions that follow it in the dockerfile.
- ENV: syntax(ENV key value); sets environment variables in the container.
- EXPOSE: syntax(EXPOSE port); this command informs docker that the container listens on the specified network ports at runtime. it does not actually make the ports accessible from outside the container.
- CMD: syntax(CMD command || CMD ["executable", "param1", "param2"]); specifies the default command to run when the container starts, there can only be one CMD instruction in a dockerfile, if multiple CMD instructions are provided, only the last one will take effect, it can be overridden from the docker command line interface (CLI) while running the container.
- ENTRYPOINT: syntax(ENTRYPOINT command || ENTRYPOINT ["executable", "param1", "param2"]); specifies the executable that should be run when the container starts. it cannot be overriden while executing docker containers with CLI parameters.
- VOLUME: syntax(VOLUME path); This command creates a mount point with the specified name and marks it as externally mounted.
for more explanation about how CMD and ENTRYPOINT works and the differences between them, go to "https://devtron.ai/blog/cmd-and-entrypoint-differences/" .
- what is NGINX ?
NGINX is a popular open-source web server software known for its hogh performance, stability, and scalability. it's often used as a front-end web server or proxy server, sitting between clients and backend application servers. NGINX is commonly used to improve the performance and reliability of websites and web applications by efficiently distributing incoming web traffic and handling requests in an optimized manner.
- what is openssl ?
OpenSSL is a widely-used open-source toolkit implementing the Secure Sockets Layer (SSL) and Transport Layer Security (TLS) protocols, along with general-purpose cryptography functions. It provides libraries and command-line tools for secure communication over computer networks. it provides libraries and APIs for developers to integrate SSL/TLS functionality into their applications. This enables secure communication channels for protocols like HTTPS, FTPS, SMTPS, and many others.
- what is SSL (Secure Sockets Layer) TLS (Transport Layer Security) protocols ?
SSL and its successor TLS are cryptographic protocols used to secure communication over a computer network, most commonly the internet. They provide privacy, data integrity, and authentication between two communicating applications. SSL/TLS works by encrypting data transmitted between a client (such as a web browser) and a server (such as a website). This encryption ensures that even if intercepted, the data remains private and secure.
to generate a self-signed ssl certeficate using Openssl :
- openssl genrsa -out file.key 2048 : this command generates a 2048-bit RSA(Rivest-Shamir-Adleman : names of the inventors of the RSA encryption) private key and saves it in the file.key.
- openssl req -new -key file.key -out file.csr : this command is used to generate a CSR (Certificate Signing Request).
- openssl x509 -req -days 365 -in file.csr -signkey file.key -out file.crt : This command generates a self-signed certificate valid for 365 days using the CSR and private key previously generated. The certificate is saved in a file named file.crt.