The best way to install and upgrade for Linux docker
Tags: docker, linux, fmzquant, trading
Published: 2024-05-16 01:15:04

### Note
- For digital currency, overseas dockers should be selected. For commodity futures, you can rent domestic servers monthly with one click on FMZ platform, and the price is close to the lowest. One click rental of overseas dockers is more expensive.
- A docker can run multiple robots.
- A server can run multiple dockers, but it is generally unnecessary.
- If you are prompted that Python cannot be found, you need to install and restart it on the machine running the docker.
- The latest docker (March 1, 2021) has upgraded the automatic background. That is, after the foreground runs, you can exit the ssh connection directly without interrupting the docker. The original method can still be used.

### Overseas server recommendation
Alibaba Cloud, [Alibaba Cloud Lightweight Application Server](https://account.aliyun.com/login/login.htm?oauth_callback=https%3A%2F%2Fcommon-buy.aliyun.com%2F%3Fspm%3D5176.161059.835498.1.486e7fdaOqyu7a%26commodityCode%3Dswas%26request%3D%257B%2522image_type%2522%3A%2522appimage%2522%2C%2522app_image%2522%3A%2522b2542b3988834a378c67a8d7f11ad4de%2522%2C%2522version_type%2522%3A%2522version_2%2522%2C%2522order_num%2522%3A1%2C%2522ord_time%2522%3A%252212%3AMonth%2522%2C%2522auto_renew%2522%3Afalse%257D%26aly_as%3D8B_geGiSf%26regionId%3Dcn-hongkong#/buy) select Hong Kong (OKX is in Hong Kong), system image CentOS, package is 34 yuan/month, 2G RAM. Pay monthly (or half a year). It is a cost-effective option currently.

Amazon ec2 has many optional regions, and the Binance and Huobi Exchanges have the option of Tokyo, with the lowest delay. Generally, the lowest configuration t2.small is enough. But you need to bind a visa credit card to pay.

Vultr is cheap and has many options. It supports Alipay payment. However, the server and website may be blocked, and the correct Internet access is required.

### Linux installation docker steps
1. To purchase a server, you usually choose the centOS system with the minimum configuration. The general price is 1 yuan/day. Commodity futures are served in the domestic market, while digital currency transactions are carried out abroad. [Here is a specific purchase demonstration](https://study.163.com/course/courseLearn.htm?courseId=1006074239&share=2&shareId=400000000602076#/learn/video?lessonId=1053492476&courseId=1006074239).
2. Log in to the server. Windows recommends using the Xshell client. The specific SSH login method can be searched by yourself.
3. Download the docker, right click on https://www.fmz.com/m/add-node to copy the link of the docker that matches the system version. Note that the command run in step 5 should also be viewed here.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/igrda0ayn2x0mu3xmxc7.png)

Server input: wget https://www.fmz.com/dist/robot_linux_amd64.tar.gz to download (the Shift+Ins key is pasted on the terminal). If prompted that wget does not exist, run yum install wget - y to install wget. Other systems also have corresponding download tools.
If a certificate problem is prompted (as shown in the following figure):

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/z98lybik63ge0en6pese.png)

- When downloading with wget you can use: --no-check-certificate parameter.
For example: wget --no-check-certificate https://www.fmz.com/dist/robot_linux_amd64.tar.gz

- When downloading with curl you can use: -k parameter.
For example: curl -O -k https://www.fmz.com/dist/robot_linux_amd64.tar.gz

4. Run tar - xzvf robot_linux_amd64.tar.gz to decompress (after entering the robot, press TAB to complete the path automatically).
5. To test docker need to run ./robot -s node. fmz. com/xxxxxx -p yourFMZpassword, the number string represented by xxxxxx is different for each user. The details are found at https://www.fmz.com/m/add-node. YourFMZpassword represents your FMZ website login password, which is required to decrypt API Key.
Prompt such as: 2018/07/05 05:04:10 Login OK, SID: 62086, PID: 7226, Name: host. localdomain, the operation succeeds. If you encounter permission problems, run chmod +x robot.
6. At this time, the docker runs in the foreground, and it will be disconnected when the SSH connection is closed. It needs to run in the background. Press ctrl+C to end the test.
7. Run the command nohup ./robot -s node.fmz.com/xxxxxx -p yourFMZpassword & in the background.
8. You can see the deployed docker on the docker page. After the page is deleted, the server docker will exit automatically.
9. You can also use the screen command to make the docker run in the background. You can enter the password without explicitly (the command parameter does not add -p), and you can search for it by yourself.

### Upgrade steps
**Dockers on FMZ generally do not need to be upgraded. If new exchanges are added, bugs are modified, or dockers are too old, they can be upgraded as the following steps:**

 1. Log in to the directory where the server docker is located (if it has not been changed, it is generally the default directory after SSH login) and execute ls to view the file.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ynilc8m9fr9nrh9ohsw0.png)

  We can see logs robot robot_linux_amd64.tar.gz, where logs is the log folder, robot is the docker execution program, and robot_linux_amd64.tar.gz is the original compressed package.
 2. Execute rm - rf robot* to delete the old robot program and compressed file package at the same time, and keep the log.
 3. Execute wget https://www.fmz.com/dist/robot_linux_amd64.tar.gz to download a new docker package.
 4. Execute tar -xzvf robot_linux_amd64.tar.gz to unzip.
 5. Execute nohup ./robot - s node.fmz.com/xxxxxx - p yourFMZpassword & to run in the background, node.fmz.com/xxxxxx can be found in https://www.fmz.com/m/add-node.

The advantage of upgrading in this way is that the log can be retained, and the robots run by the old docker will not stop (they have been loaded into memory to run). To upgrade the docker of a robot, you only need to stop the robot, change the docker in the parameter interface (the id of the latest docker is the largest) and restart.

If the old docker no longer runs the robot, the page can be deleted directly on https://www.fmz.com/m/nodes.

From: https://blog.mathquant.com/2023/01/10/the-best-way-to-install-and-upgrade-for-linux-docker.html