Article directory
Preface
Docker is an open source containerization platform that allows developers to package applications and their dependencies into a portable container to easily deploy, run and manage applications. Docker's container technology can package all the software, libraries and configuration files required to run an application into a container, and then publish the container to any server that supports Docker for deployment without worrying about the configuration of the intermediate environment. Using Docker, developers can quickly build, test and deliver applications, greatly shortening the development cycle and deployment time, and improving development efficiency. At the same time, because Docker's container technology can isolate different applications and services, it ensures the security and reliability between them and reduces the risk of application errors and crashes. Therefore, Docker has become one of the widely used virtualization technologies today and has been widely welcomed and applied.
1. docker official website
https://docs.docker.com/
2. Install docker
Install using Ubuntu:
https://docs.docker.com/engine/install/ubuntu/
1. The first method (official)
Install directly using the official installation method:
- Set up the repository:
Update the package index and install the package to allow the use of HTTPS-based repositories:
sudo apt-get update
sudo apt-get install ca-certificates curl gnupg
- Add Docker's official GPG key:
sudo install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o/etc/apt/keyrings/docker.gpg
sudo chmod a+r /etc/apt/keyrings/docker.gpg
- Set up the repository using the following command:
echo \
"deb [arch="$(dpkg --print-architecture)" signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
"$(. /etc/os-release && echo "$VERSION_CODENAME")" stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
- Install Docker engine
and update package index: apt
sudo apt-get update
- Install Docker Engine, containerd and Docker Compose.
Specific version:
# List the available versions:
apt-cache madison docker-ce | awk '{ print $3 }'
5:24.0.0-1~ubuntu.22.04~jammy
5:23.0.6-1~ubuntu.22.04~jammy
<...>
要安装最新版本,请运行:
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
- Verify
Verify that the Docker engine installation was successful by running the image. hello-world
sudo docker run hello-world
Successful installation:
2. Use script installation (Alibaba Cloud):
Alibaba's automated scripts have encapsulated the commands and can be installed by running them directly:
curl -fsSL https://get.docker.com | bash -s docker --mirror Aliyun
3. Install using the official script:
curl -fsSL https://test.docker.com -o test-docker.sh
sudo sh test-docker.sh
Pull the image (solo blog deployment)
Here I deploy a blog system:
docker pull mysql:latest
docker images
docker run -itd --name mysql-test -p 3306:3306 -e MYSQL_ROOT_PASSWORD=julien_qiao mysql
Enter the container:
Create a database:
部署一个solo的博客系统:
docker pull b3log/solo
docker run --detach --name solo --network=host \
--env RUNTIME_DB="MYSQL" \
--env JDBC_USERNAME="root" \
--env JDBC_PASSWORD="julien_qiao" \
--env JDBC_DRIVER="com.mysql.cj.jdbc.Driver" \
--env JDBC_URL="jdbc:mysql://127.0.0.1:3306/solo?useUnicode=yes&characterEncoding=UTF-8&useSSL=false&serverTimezone=UTC&allowPublicKeyRetrieval=true" \
b3log/solo --listen_port=8080 --server_scheme=http --server_host=localhost --server_port=
Access address + port:
The cloud host used here prohibits access to port 3306 (security):
simple deployment is completed: