본문 바로가기

Projects/Docker with JJ

1. Toy Project Discussion

0. why do we use Docker?

https://www.cloudthat.com/resources/blog/docker-game-changer-in-the-world-of-cloud-and-virtualization

 

The existing virtualization method was bound to be very heavy and slow because each virtual environment had an independent kernel OS. In addition, the performance and environment of the computer are limited because the resources available for each environment are fixed. 

However, Docker's virtualization method does not create a new kernel OS, but inherits and uses the existing kernel OS resources. In addition, resources that can be used in each environment are not fixed, so they can change fluidly.

 

In conclusion, the reasons why Docker should be used are as follows.

1) Environmental Consistency: Docker provides the same environment in development, testing, and production environments, which minimizes environmental errors and ensures consistency.


2) Quick deployment and scalability: Docker allows you to package web applications and all the dependencies they need into containers. These containers can be deployed and run quickly on any system. They can also be easily scaled up to meet your needs in docker environments.


3) Resource Efficiency: Docker provides a virtualized environment, so you can use the resources you need efficiently. You can run multiple containers on a single machine at the same time, and each container uses minimal resources for your work.


4) Isolated Environment: Docker containers run in isolated environments. This ensures the independence and security of each web application.


5) Version management and restoration: Docker images provide version management, which allows you to easily roll back to an earlier version or test a new version.


6) Continuous Integration/Continuous Deployment (CI/CD): Docker integrates well with the CI/CD pipeline. Helps quickly test code changes and deploy them to production.


1. Studying Process

Overall Pipeline

 

The Concept of Docker

-> How to use Docker? (Docker install, Docker command, Lightsail ...)

-> Frontend, Backend, DB (3-tier Service)

-> Frontend(Javescript, React)

-> Backend(Fastapi, python)

-> DB(mySQL, dbeaver, sqlarchemy)

-> Reverse Proxy(Nginx)

-> make web application using Amazon Lightsail (free resource for application site) - our First Goal

-> CI / CD

-> Docker CLI or Docker Compose

-> Docker hub, GitAction (CI)

-> Kubernetes (Multi-docker Container)

 


2. How to use Docker?

1. Installing the Default Package

 

Before installation, you must verify that the Linux kernel must be at least 3.10 version and that it is 64 bits (x86_64).

uname -a

 

You can check the kernel information and bits of your Linux environment through the above commands.

 

sudo apt update

 

It also updates the apt version before the apt-get install for future use.

 

sudo apt-get install -y apt-transport-https ca-certificates curl gnupg-agent software-properties-common

 

A command that installs the packages required to use Docker. To explain the above commands in turn,

1) apt-transport-https: Installs the web address required to download the ce version (a lighter version) from Docker to use https.

2) ca-certificates : since https is SSL, certificate functionality is required and installed.

3) curl : Install because it is required by API communication.

4) gnupg-agent : Install gnu package guard among package guards used by Docker.

5) software-properties-common —Install to access and manage the docker repository.


2. Install Docker Engine

 

Starting with Ubuntu 22.04 version, we recommend storing apt keys in .gpg keys using a technique called keyring for added security.

curl -fsSl https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/shere/keyrings/docker-archive-keyring.gpg

 

curl -fsSl https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -

 

Use the command above to register the key value in the keyring. You will probably see the warning apt-key is defined.

sudo apt-key fingerprint

 

You can check the key value registered in the part called Docker Release through the command above.

echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

 

 

Install a stable of the release versions of the dubian series dubuntu using the key value in the keyring.

 

sudo apt -y update
 
After adding repository, it is recommended to update apt.

 

 

sudo apt -y install docker-ce

 

Finally, install docker-ce.

 

sudo docker version

 

 

If you are bothered to use sudo command every time in Docker, you can register my account and use the docker command without sudo.

 

sudo usermod -aG docker [My account]
sudo systemctl daemon-reload
sudo systemctl enable docekr
sudo systemctl restart docker
sudo reboot

 

 

Now, you can use the docker as much as you want.