Recently I was looking at how Docker allows containers to directly run certain processes when they start, and later I found that Dockerfile can specify the container running command when the container starts. CMD specifies, but each Dockerfile can only have one CMD instruction. If multiple CMD instructions are specified, only the last one will be executed. So I thought of a way, wrote a script, started multiple processes in the script, and ran the script in Dockerfile. Finally, this method was proved to be feasible. However, a problem was encountered during the experiment. The container stopped immediately after starting. After consulting the information: A Docker container can only manage one process at a time. If this process exits, the container will also exit. However, this does not mean that the container can only run one process (other processes can run in the background). However, in order for the container to not exit, there must be a process executing in the foreground. Solution: The last process in the script must be run in foreground mode, that is, do not add & (& means background running) at the end of the process, otherwise the container will exit. Supplementary knowledge: Problems and solutions when using gdbserver in a docker container I have a problem when using gdbserver in a docker container
The reason is that Docker disables the PTRACE function by default and needs to be enabled when the container is running.
The above article on solving the problem of docker container exiting immediately after starting is all the content that the editor shares with you. I hope it can give you a reference, and I also hope that you will support 123WORDPRESS.COM. You may also be interested in:
|
<<: Document Object Model (DOM) in JavaScript
>>: Introduction to HTML DOM_PowerNode Java Academy
Table of contents 1. Traversal Class 1. forEach 2...
Table of contents Single content projection Multi...
Preface There are many devices nowadays, includin...
Table of contents Multi-table join query Inner Jo...
1. Postgres database backup in Docker Order: dock...
Basic Introduction In the previous article, we in...
<button> tag <br />Definition and usag...
Record the installation of two MySQL5.6.35 databa...
Table of contents 1. ChildNodes attribute travers...
Table of contents Join syntax: 1. InnerJOIN: (Inn...
Today I got familiar with the mouse zooming effect...
Preface The latest version of MySQL 8.0 is 8.0.4 ...
This article shares the specific code of JavaScri...
Table of contents 1. Demand 2. Effect 3. All code...
When dynamically concatenating strings, we often ...