[Linux/Ubuntu] Problems encountered when deploying docker

1. Install docker+docker-compose

For docker installation, refer to the following two links, among which I think Tencent Cloud’s explanation is more detailed and professional. The package installed by apt is docker-ce, which means community edition.
Docker Tutorial
Tencent Cloud How to Install and Use Docker on Ubuntu

1. When apt installs the package, it warns that the kernel version version is incorrect

─────────────────────────────────────────────── Pending kernel upgrade ├───────────────────────────────────────────────┐
│                                                                                                                        │
│ Newer kernel available                                                                                                 │
│                                                                                                                        │
│ The currently running kernel version is 5.15.0-41-generic which is not the expected kernel version 5.15.0-43-generic.  │
│                                                                                                                        │
│ Restarting the system to load the new kernel will not be handled automatically, so you should consider rebooting.      │
│                                                                                                                        │
│                                                         <Ok>

warning-1
warning-2
Solve Reference 1
Solve Reference 2, focusing on the needrestart package mentioned in 1

X、docker: Cannot connect to the Docker daemon. Is the docker daemon running on this host?.

If this prompt appears when using the docker command, then by default, the docker command can only be run by the root user or users in the docker group. To run docker commands without typing sudo, add the username to the docker group:

sudo usermod -aG docker ${
    
    USER}

2、docker: Got permission denied while trying to connect to the Docker daemon socket at 网址: Post 网址: dial unix /var/run/docker.sock: connect: permission denie

After installing and testing whether docker can run, enter the command docker run --rm hello-worldand jump out of this error. Adding sudo in front can be solved violently, it is estimated that it is a permission problem.
Solve reference one

3. Use sudo curlprompts when installing docker-compose-bash 路径 permission denied

[For the second installation, just refer to the official document and type two lines of commands. There is no problem. In the official document , docker compose has no dashes in this version (I feel that the ones with dashes have been eliminated)]
Use sudo Still can't brute force it, but it's still a permission issue. Use sudo suto switch to the root user, and then run the relevant command.

4. After installing docker-compose, execute the command prompt/usr/local/bin/docker-compose: line 1: Not: command not found

Use according to a tutorial website of docker

sudo curl -L https://download.fastgit.org/docker/compose/releases/download/2.9.0/docker-compose-`uname -s`-`uname -m` > /usr/libexec/docker/cli-plugins/docker-compose

Just changed the version number. After searching, it was found that the version number did not add v.

The correct command should be

sudo curl -L https://download.fastgit.org/docker/compose/releases/download/v2.9.0/docker-compose-`uname -s`-`uname -m` > /usr/libexec/docker/cli-plugins/docker-compose

5. After installing docker-compose according to the command, it prompts that it is not installed

Remember to weight chmod +x /usr/local/bin/docker-composeit with executable-only, otherwise the system won't be able to find it, and in ls mode it's a white file, which means normal files. After weighting, it will turn green, which is an executable file.
Regarding compose-switchthe use of plug-ins (because docker-compose V1 is written in python, the call statement is docker-compose, while docker-compose V2 is written in go, it is installed in docker cli-plugins文件夹下as a plug-in, and the call statement becomes docker compose, which is integrated in docker )
I have been working on it for a long time and have not successfully used this plug-in, forget it, but I still need to post the good method I found.
resolve reference

2. Use of remote server

1. Screen-Solve the problem of Putty link disconnection program termination, multi-window solution

Screen-Solve the Putty link disconnection program termination problem

Three, docker deployment

1. Postman access, nginx side does not respond at all

The port connection is wrong.

2. Postman access, the nginx side outputs some garbled characters, returns 400, and postman displays an errorError: write EPROTO 196872:error:100000f7:SSL routines:OPENSSL_internal:WRONG_VERSION_NUMBER:../../../../src/third_party/boringssl/src/ssl/tls_record.cc:242:

https is used in the URL, just remove the s and use http

3. Nginx and postman can display normally, but nginx displays 502 error, and postman getsBad Gateway

The service in the django container is not started, just go through it again.

4. The file cannot be transferred

Postman transfers the file, and returns { "error": "The data can't be found in database. [Errno 13] Permission denied: '/usr/local/lib/python3.8/site-packages/cms/media/software packages'", "status": 101025 }
whether it is a small file or a large file, it cannot be uploaded. First, the reason for the size of the nginx configuration file is ruled out. It should be a file permission issue.
In the media file mapped from the django container to the server, it is found that the permissions of the media file have not been opened to the maximum chmod -R 777 media.
The strange thing is that this statement has already been written in the Dockerfile of the web container, but why it is useless to execute needs to be checked.

Guess you like

Origin blog.csdn.net/qq_42438771/article/details/126138964