mirror of https://github.com/docker/docs.git
engine: restructure mult-service container page
Signed-off-by: David Karlsson <david.karlsson@docker.com>
This commit is contained in:
parent
7079dc4572
commit
a2d22f16e6
|
@ -10,8 +10,8 @@ title: Run multiple services in a container
|
||||||
---
|
---
|
||||||
|
|
||||||
A container's main running process is the `ENTRYPOINT` and/or `CMD` at the
|
A container's main running process is the `ENTRYPOINT` and/or `CMD` at the
|
||||||
end of the `Dockerfile`. It is generally recommended that you separate areas of
|
end of the `Dockerfile`. It's best practice to separate areas of concern by
|
||||||
concern by using one service per container. That service may fork into multiple
|
using one service per container. That service may fork into multiple
|
||||||
processes (for example, Apache web server starts multiple worker processes).
|
processes (for example, Apache web server starts multiple worker processes).
|
||||||
It's ok to have multiple processes, but to get the most benefit out of Docker,
|
It's ok to have multiple processes, but to get the most benefit out of Docker,
|
||||||
avoid one container being responsible for multiple aspects of your overall
|
avoid one container being responsible for multiple aspects of your overall
|
||||||
|
@ -28,10 +28,12 @@ container exits. Handling such processes this way is superior to using a
|
||||||
full-fledged init process such as `sysvinit`, `upstart`, or `systemd` to handle
|
full-fledged init process such as `sysvinit`, `upstart`, or `systemd` to handle
|
||||||
process lifecycle within your container.
|
process lifecycle within your container.
|
||||||
|
|
||||||
If you need to run more than one service within a container, you can accomplish
|
If you need to run more than one service within a container, you can achieve
|
||||||
this in a few different ways.
|
this in a few different ways.
|
||||||
|
|
||||||
- Put all of your commands in a wrapper script, complete with testing and
|
## Use a wrapper script
|
||||||
|
|
||||||
|
Put all of your commands in a wrapper script, complete with testing and
|
||||||
debugging information. Run the wrapper script as your `CMD`. This is a very
|
debugging information. Run the wrapper script as your `CMD`. This is a very
|
||||||
naive example. First, the wrapper script:
|
naive example. First, the wrapper script:
|
||||||
|
|
||||||
|
@ -62,7 +64,9 @@ this in a few different ways.
|
||||||
CMD ./my_wrapper_script.sh
|
CMD ./my_wrapper_script.sh
|
||||||
```
|
```
|
||||||
|
|
||||||
- If you have one main process that needs to start first and stay running but
|
## Use Bash job controls
|
||||||
|
|
||||||
|
If you have one main process that needs to start first and stay running but
|
||||||
you temporarily need to run some other processes (perhaps to interact with
|
you temporarily need to run some other processes (perhaps to interact with
|
||||||
the main process) then you can use bash's job control to facilitate that.
|
the main process) then you can use bash's job control to facilitate that.
|
||||||
First, the wrapper script:
|
First, the wrapper script:
|
||||||
|
@ -97,7 +101,9 @@ this in a few different ways.
|
||||||
CMD ./my_wrapper_script.sh
|
CMD ./my_wrapper_script.sh
|
||||||
```
|
```
|
||||||
|
|
||||||
- Use a process manager like `supervisord`. This is a moderately heavy-weight
|
## Use a process manager
|
||||||
|
|
||||||
|
Use a process manager like `supervisord`. This is a moderately heavy-weight
|
||||||
approach that requires you to package `supervisord` and its configuration in
|
approach that requires you to package `supervisord` and its configuration in
|
||||||
your image (or base your image on one that includes `supervisord`), along with
|
your image (or base your image on one that includes `supervisord`), along with
|
||||||
the different applications it manages. Then you start `supervisord`, which
|
the different applications it manages. Then you start `supervisord`, which
|
||||||
|
|
Loading…
Reference in New Issue