current position:Home>About the problem that the container will hang up after starting nginx in the docker container
About the problem that the container will hang up after starting nginx in the docker container
2022-05-15 02:55:16【Common program ape】
Recently tried based on nginx Made a mirror image , stay Dockerfile Call a script in , This script is used to modify... According to the parameters passed in at startup nginx Default profile , And then restart nginx service .Dockerfile It's about :
FROM nginx:alpine
ENV backend_api_url xxx
ADD launch.sh /launch.sh
EXPOSE 80
ENTRYPOINT [ "sh", "/launch.sh" ]
then launch.sh The main content of the script is to modify nginx.conf Configuration in file , perform nginx Start command . But after writing, the deployment found that the image can build success , But when you start a container, it always fails , Tried all kinds of start-up methods, but it didn't work .
Finally, after consulting the data, we found an effective method : Use... In scripts nginx -g "daemon off;"
To start up nginx.
Principle analysis
stay docker In the container pid=1 After the process of hangs up, the whole container will hang up , Based on nginx In terms of containers , Default pid=1 This is the process of nginx, But once you are Dockerfile Use in CMD perhaps ENTRYPOINT after , The corresponding program will replace nginx Turn into pid=1 The process of , For example, in my example above launch.sh, And once the script is executed, exit , The container will stop . When using nginx -g "daemon off;" Then tell me nginx Do not exit after startup , So as to ensure the normal operation of the generated container .
copyright notice
author[Common program ape],Please bring the original link to reprint, thank you.
https://en.qdmana.com/2022/132/202205120035143569.html
The sidebar is recommended
- React error report record
- Analysis of react life cycle function
- react demo1 TodoList
- Summary of the differences between state and props in react
- Difference between controlled components and uncontrolled components in react
- Node. JS use get Stream download file
- How does JavaScript copy arrays instead of references
- JavaScript calculates the number of days, hours, minutes and seconds between days
- JQuery get page address parameters
- JavaScript create Download
guess what you like
node. JS traversal directory
Tips for using JavaScript string split (how to keep the delimiter)
Common CSS notes
JavaScript usage Get the address of the regular function
New generation node JS web development framework koa zero foundation entry learning notes
JavaScript notes
asp. Net core method for modifying HTML without rerun
Summary of compatibility processing of H5 + Vue cli project in Safari browser
Summary of amap scheme of Gaode map used in vue3 + TS project
Summary of filter scheme used in JS code in Vue
Random recommended
- Build an electron project based on Vue from scratch
- In Vue project, solve the problem of verification conflict when eslint and prettier are used at the same time
- Vue3 + vuecli4 solve chunk vendors JS file is too large. Scheme summary
- Scheme summary of eslint check before vue3 + vite configuration project operation and eslint check before git submission
- Fatal authentication failed for 'httpxxxx Git 'solution
- Vue's solution to the compatibility of hevc encoded video in each end browser
- Record the solution to the error in obtaining the picture in springboot in Vue
- [Vue] detailed analysis of the life cycle function of Vue components
- [Vue] deeper understanding of user-defined attribute props
- [Vue] front end error: cannot read properties of undefined (reading 'split')
- [Vue] asynchronous problem of component value transfer -- the sub component gets the data slowly
- [Vue] Vue data changes, but the page is not updated in real time
- [element UI] use of form verification -- detailed explanation
- [Vue] use of slots - Review
- The influence on the fixed positioning element of the inner layer when the outer element has a fixed height and overflows and rolls
- Precautions
- Change detection strategy of angular component
- Angular service and @ injectable
- JS, HTML and CSS are not compatible and do not use common knowledge
- Properties to be known in angular @ component
- Angular acquisition and operation DOM
- Html2canvas problem
- Use day in Vue JS (time and date processing library)
- Vue cli configuring preprocessor global variables (take less as an example)
- How to use H5 custom tags in Vue?
- Come on, vue2 customize global loading
- Come on, Vue move the end suspension ball assembly
- React routing foundation and transmission parameters
- Come on, Vue graphic verification code component
- JavaScript judges browser types and kernels at home and abroad (including 360, QQ, Sogou, etc.)
- ArcGIS JavaScript 4. Generates a rectangular buffer at the point of X
- Node under window JS installation, environment configuration, setting Taobao image
- Understanding of prototype and prototype object of JavaScript
- How to customize the startup port of react project!
- Why vue3 0 using proxy to realize data listening 2021-06-21
- Front end artifact - download, configuration and use process of Charles (vase) [Mac version]
- React next configures SVG loader and supports SVG configurability
- React native Android phone cannot be opened after installation. Flash back!
- Fetch and Axios failed to request on Android, with error messages: network request failed and network error
- How to upgrade react Babel 7.1.0