Server Deployment Project
Article directory
I purchased a server on Tencent Cloud, here is the official website link— Tencent Cloud official website .
1. Connect to the server remotely
First reset the password on the details page of the purchased server, and then open port 22 of the server.
After completing the above operations, open XShell, fill in the public network IP and port, and select the SSH protocol. Click Connect and fill in the user name and password to successfully connect to the cloud server.
2. Install Docker on the Linux system
Docker can be installed on 64-bit x86 platform or ARM platform. In the Ubuntu distribution, the LTS (Long-Term-Support) long-term support version will receive 5 years of upgrade and maintenance support. Such a version will be more stable, so it is recommended to use the LTS version in the production environment.
2.1 Uninstall the old version
Older versions of Docker are called docker
or docker-engine
, uninstall older versions with the following command:
$ sudo apt-get remove docker docker-engine docker.io
2.2 Install using APT
Since the apt source uses HTTPS to ensure that the software download process is not tampered with. Therefore, we first need to add the package delivered using HTTPS and the CA certificate.
$ sudo apt-get update
$ sudo apt-get install \
apt-transport-https \
ca-certificates \
curl \
gnupg \
lsb-release
In view of domestic network problems, it is strongly recommended to use domestic sources, please check the official sources in the comments.
In order to confirm the legitimacy of the downloaded software package, it is necessary to add GPG
the key .
$ curl -fsSL https://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
# 官方源
# $ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
Then, we need to add the Docker repository sources.list
to .
$ echo \
"deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://mirrors.aliyun.com/docker-ce/linux/ubuntu \
$(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
# 官方源
# $ echo \
# "deb [arch=amd64 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
2.3 Install Docker
Update the apt package cache, and install docker-ce
:
$ sudo apt-get update
$ sudo apt-get install docker-ce docker-ce-cli containerd.io
2.4 Automatic installation using scripts
In the test or development environment, in order to simplify the installation process, Docker officially provides a set of convenient installation scripts, which can be used to install on the Ubuntu system. In addition, you can use --mirror
the option Need to get the script from test.docker.com):
# $ curl -fsSL test.docker.com -o get-docker.sh
$ curl -fsSL get.docker.com -o get-docker.sh
$ sudo sh get-docker.sh --mirror Aliyun
# $ sudo sh get-docker.sh --mirror AzureChinaCloud
After executing this command, the script will automatically prepare everything and install the stable version of Docker in the system.
2.5 Start Docker
$ sudo systemctl enable docker
$ sudo systemctl start docker
2.6 Test whether Docker is installed correctly
hello-world
Verify that Docker is successfully installed through the image.
$ sudo docker run --rm hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
2db29710123e: Pull complete
Digest: sha256:6d60b42fdd5a0aa8a718b5f2eab139868bb4fa9a03c9fe1a59ed4946317c4318
Status: Downloaded newer image for hello-world:latest
Hello from Docker!
This message shows that your installation appears to be working correctly.
To generate this message, Docker took the following steps:
1. The Docker client contacted the Docker daemon.
2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
(amd64)
3. The Docker daemon created a new container from that image which runs the
executable that produces the output you are currently reading.
4. The Docker daemon streamed that output to the Docker client, which sent it
to your terminal.
To try something more ambitious, you can run an Ubuntu container with:
$ docker run -it ubuntu bash
Share images, automate workflows, and more with a free Docker ID:
https://hub.docker.com/
For more examples and ideas, visit:
https://docs.docker.com/get-started/
If the above information can be output normally, the installation is successful.
2.7 Using Mirror Accelerator
After installing the Docker software, you can directly pull the image through docker pull
the command . If the image acceleration source is not configured and the image in DockerHub is pulled directly, the download speed will usually be slower.
Execute the following command to modify the /etc/docker/daemon.json
configuration file.
$ sudo vim /etc/docker/daemon.json
Add the following content, make sure the file conforms to the json specification, otherwise Docker will not start.
{
"registry-mirrors": [
"https://mirror.ccs.tencentyun.com"
]
}
After that restart the service.
$ sudo systemctl daemon-reload
$ sudo systemctl restart docker
2.8 Uninstall Docekr
Uninstall the Docker engine, CLI and Containerd packages:
$ sudo apt-get purge docker-ce docker-ce-cli containerd.io
Images, containers, volumes, or custom configuration files on the host are not automatically deleted. To delete all images, containers and volumes execute the following command:
$ sudo rm -rf /var/lib/docker
$ sudo rm -rf /var/lib/containerd
3. Pull the project image
3.1 Login account
If you don't have an account yet, you can register one on Docker Hub . Use the following command to log in:
$ sudo docker login
You can view the login status through the config.json file.
$ sudo cat /root/.docker/config.json
The logout command is as follows.
$ sudo docker logout
3.2 Pull the image
Use the following command to pull the project image of the personal warehouse.
$ sudo docker pull username/image:tag
4. Use of the Services
First, generate the corresponding container according to the pulled project image with docker run
instructions (pay attention to setting the port mapping), open the project service in the container, and open the corresponding port number in the firewall setting of the server, and then you can use the corresponding service.
Here are the two projects I deployed on the server:
Open flame smoke target detection project: http://121.4.107.27:5001/
Medical question and answer assistant project [still in progress]: http://121.4.107.27:5002/