About Docker
I learnt a little bit about Docker today when I am figuring out how to customize this website.
The first time I heard about Docker is from the TA of my Software Engineering class. I will write about how I installed Docker on my pc and what I got to know on it. (I only leant a little from some article, but I want to record it down).
Docker is a tool used to create, deploy, and run applications using containers.
From my understanding, Docker is just a process used to ensure the running environment on different machines are the same.
For example, If an app is developed firstly by A, if A directly sends the app to B for testing, B needs to recreate the same environment as A to ensure the correctness of testing output. It requires B to put extra efforts before woking on the test.
If we use Docker, A can package the app and ship the package to container held by Docker, and B on the other side can rechieve the package and directly head to the test, because Docker can set up the same environment for B! Even if A and B have different OS, Docker can still handle the situation.
Docker is a light Virtual Machine, but it does not create the entire virtual operating system as Virtual Machine does. As a result, Docker is fast in start, requires fewer resources, and very efficient compared to VM.
Install Docker on WSL 2
I followed this offical document to install Docker on WSL of my PC.
Basically, we need to dowload Docker Desktop, and add extensions in VS Code. There is a simple instance provided in this document.
Here are some useful demands:
List the commands available in the Docker CLI by entering: docker
List information for a specific command with: docker <COMMAND> --help
List the docker images on your machine (which is just the hello-world image at this point), with: docker image ls --all
List the containers on your machine, with:docker container ls --all
ordocker ps -a
(without the -a show all flag, only running containers will be displayed)
List system-wide information regarding the Docker installation, including statistics and resources (CPU & memory) available to you in the WSL 2 context, with: docker info
Delete the container(s): docker rm + ID of containers(can use docker ps -a to get ID)
This is a useful article in Chinese, which introduces to basic logic of Docker.
I only know a little about Docker, and it is important to learn from practical use.
2/26/2024
Use Docker on the full-stack project