[Cloud Computing] Multiple ways to install docker in Ubuntu


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/
Example: pandas is a tool based on NumPy that was created to solve data analysis tasks.

2. Install docker

Install using Ubuntu:
https://docs.docker.com/engine/install/ubuntu/
Insert image description here
Insert image description here

1. The first method (official)

Install directly using the official installation method:

  1. 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
  1. 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
  1. 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
  1. Install Docker engine
    and update package index: apt
sudo apt-get update
  1. 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
  1. Verify
    Verify that the Docker engine installation was successful by running the image. hello-world
 sudo docker run hello-world

Insert image description here

Insert image description here
Successful installation:
Insert image description here

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

Insert image description here

Insert image description here
Enter the container:

Insert image description here

Insert image description here

Create a database:
Insert image description here

部署一个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=

Insert image description here
Access address + port:
Insert image description here
The cloud host used here prohibits access to port 3306 (security):
Insert image description here
simple deployment is completed:
Insert image description here

Guess you like

Origin blog.csdn.net/qq_39583774/article/details/131170894