Skip to content

Commit cb2827b

Browse files
authored
Update README.md
1 parent c73aa45 commit cb2827b

File tree

1 file changed

+31
-17
lines changed

1 file changed

+31
-17
lines changed

README.md

Lines changed: 31 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# Docker Python Waitress
1+
# Python Waitress Docker Container
22

3-
Docker container to run a WSGI Python app using
3+
A Docker container to run a WSGI Python application using
44
[Waitress](https://docs.pylonsproject.org/projects/waitress/en/stable/index.html). Images support python 3.6+ and are
55
based on the [official python containers](https://hub.docker.com/_/python). The `-slim` versions are based on the similarly named python versions.
66

@@ -36,14 +36,14 @@ All options can be set using environment variables. These can be passed either i
3636
-e flag to the docker call.
3737

3838
### Prestart Script
39-
If you need to run any startup commands before waitress runs (an example might be running migrations) you can override the `prestart.sh` script. This script should live within the `/app` directory in the container. The image will automatically detect and run it before starting waitress.
39+
If you need to run any startup commands before Waitress runs (an example might be running migrations) you can override the `prestart.sh` script. This script should live within the `/app` directory in the container. The image will automatically detect and run it before starting Waitress.
4040

4141

4242
### Variables
4343

4444
#### `MODULE_NAME`
4545

46-
The Python "module" (file) to be imported by Gunicorn, this module would contain the actual application in a variable.
46+
The Python "module" (file) to be imported by Waitress, this module would contain the actual application in a variable.
4747

4848
By default:
4949

@@ -83,7 +83,7 @@ docker run -d -p 80:80 -e VARIABLE_NAME="api" myimage
8383

8484
#### `APP_MODULE`
8585

86-
The string with the Python module and the variable name passed to Gunicorn.
86+
The string with the Python module and the variable name passed to Waitress.
8787

8888
By default, set based on the variables `MODULE_NAME` and `VARIABLE_NAME`:
8989

@@ -98,29 +98,33 @@ docker run -d -p 80:80 -e APP_MODULE="custom_app.custom_script:api" myimage
9898

9999
### Waitress Options
100100

101-
#### Host and Port
101+
#### Host & Port Setup
102102
By default, Waitress has been setup to server on all hostnames on port 80 using both IPv4 and IPv6. This translates to `--listen:*:80`. This works for most applications using the basic setups listed above.
103103

104104
You may have different needs so you can adjust and manipulate this by passing in environment variable to adjust the settings.
105105

106106
There are 2 options for doing this.
107107
1. Pass a comma separated list of `host:port,host:port` to the `WAITRESS_LISTEN` param
108-
2. Pass the host and port separately as `WAITRESS_HOST` and/or `WAITRESS_PORT`. If port is left out, it will default to 80.
109108

110109
The `WAITRESS_LISTEN` param takes precedence over `WAITRESS_HOST`/`WAITRESS_PORT` options, meaning if you include all 3, host and port settings will be ignored.
111110

112-
##### Some examples
113-
114-
To set waitress to use port 8080, sent the `WAITRESS_LISTEN` param like `-e WAITRESS_LISTEN=*:8080`
111+
To set Waitress to use port 8080, sent the `WAITRESS_LISTEN` param like
112+
```bash
113+
docker run -d -p 80:8080 -e WAITRESS_LISTEN=*:8080 myimage
114+
````
115115

116-
If you want only IPv4, you could use advanced param listed in the section below, but you could also use `-e WAITRESS_HOST=0.0.0.0 -e WAITRESS_PORT=80`
116+
2. Pass the host and port separately as `WAITRESS_HOST` and/or `WAITRESS_PORT`. If port is left out, it will default to 80.
117117

118+
If you want only IPv4, you could use advanced param listed in the section below, but you could also use
119+
```bash
120+
docker run -d -p 80:8080 -e WAITRESS_HOST=0.0.0.0 -e WAITRESS_PORT=8080 myimage
121+
````
118122
119123
#### Advanced Options
120124
121125
Many of the
122-
[supported options by waitress-serve](https://docs.pylonsproject.org/projects/waitress/en/stable/runner.html#invocation)
123-
are also supported by passing in environment variables. These params are only included in the call if they are included
126+
[options](https://docs.pylonsproject.org/projects/waitress/en/stable/runner.html#invocation) that can be passed to `waitress-serve`
127+
can also supported by passing in environment variables. These params are only included in the call if they are included
124128
in the environment. The supported options are:
125129
126130
| Environment Variable | Waitress Param |
@@ -139,13 +143,23 @@ in the environment. The supported options are:
139143
| WAITRESS_ASYNCORE_LOOP_TIMEOUT | --asyncore_loop_timeout=`$VAL` |
140144
| WAITRESS_ASYNCORE_USE_POLL | --asyncore_use_poll=`$VAL` |
141145
142-
Where `$VAL` is the value passed into the environment.
143-
For example to pass in 5 threads, use `-e WAITRESS_THREADS=5`
146+
Where `$VAL` is the value passed into the environment. For example, to set the number of threads to 5 use:
147+
```bash
148+
docker run -d -p 80:80 -e WAITRESS_THREADS=5 myimage
149+
````
144150
145-
For those without any value, simply pass a 1.
146-
For example to turn off IPv6, use `-e WAITRESS_NO_IPV6=1`
151+
For those without any value, simply pass a 1. For example, to turn off IPv6 use:
152+
```bash
153+
docker run -d -p 80:80 -e WAITRESS_NO_IPV6=1 myimage
154+
````
147155
148156
# Credits
149157
This dockerfile setup is based on https://github.com/tiangolo/meinheld-gunicorn-docker
150158
151159
Waitress is one of the Pylons projects: https://pylonsproject.org
160+
161+
Python is by the Python Software Foundation. https://python.org
162+
163+
Docker is by Docker, Inc. https://docker.com
164+
165+
Built using open source software.

0 commit comments

Comments
 (0)