Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commita1372d2

Browse files
committed
docs: standadize docker cli invocation style
1 parent7dd39e6 commita1372d2

File tree

1 file changed

+94
-59
lines changed

1 file changed

+94
-59
lines changed

‎docs/README.md

Lines changed: 94 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,19 @@ You can also use wildcards at the beginning and the end of host name, like `*.ba
3333
To set the default host for nginx use the env var`DEFAULT_HOST=foo.bar.com` for example
3434

3535
```console
36-
docker run -d -p 80:80 -e DEFAULT_HOST=foo.bar.com -v /var/run/docker.sock:/tmp/docker.sock:ro nginxproxy/nginx-proxy
36+
docker run --detach \
37+
--publish 80:80 \
38+
--env DEFAULT_HOST=foo.bar.com \
39+
--volume /var/run/docker.sock:/tmp/docker.sock:ro \
40+
nginxproxy/nginx-proxy
3741
```
3842

3943
nginx-proxy will then redirect all requests to a container where`VIRTUAL_HOST` is set to`DEFAULT_HOST`, if they don't match any (other)`VIRTUAL_HOST`. Using the example above requests without matching`VIRTUAL_HOST` will be redirected to a plain nginx instance after running the following command:
4044

4145
```console
42-
docker run -d -e VIRTUAL_HOST=foo.bar.com nginx
46+
docker run --detach \
47+
--env VIRTUAL_HOST=foo.bar.com \
48+
nginx
4349
```
4450

4551
###Virtual Ports
@@ -179,7 +185,12 @@ If the application runs natively on this sub-path or has a setting to do so, `VI
179185
If the requests are expected to not contain a sub-path and the generated links contain the sub-path, `VIRTUAL_DEST=/` should be used.
180186

181187
```console
182-
$ docker run -d -e VIRTUAL_HOST=example.tld -e VIRTUAL_PATH=/app1/ -e VIRTUAL_DEST=/ --name app1 app
188+
docker run --detach \
189+
--name app1 \
190+
--env VIRTUAL_HOST=example.tld \
191+
--env VIRTUAL_PATH=/app1/ \
192+
--env VIRTUAL_DEST=/ \
193+
app
183194
```
184195

185196
In this example, the incoming request `http://example.tld/app1/foo` will be proxied as `http://app1/foo` instead of `http://app1/app1/foo`.
@@ -221,7 +232,13 @@ Nginx variables such as `$scheme`, `$host`, and `$request_uri` can be used. Howe
221232
If you want to use `nginx-proxy` with different external ports that the default ones of `80` for `HTTP` traffic and `443` for `HTTPS` traffic, you'll have to use the environment variable(s) `HTTP_PORT` and/or `HTTPS_PORT` in addition to the changes to the Docker port mapping. If you change the `HTTPS` port, the redirect for `HTTPS` traffic will also be configured to redirect to the custom port. Typical usage, here with the custom ports `1080` and `10443`:
222233

223234
```console
224-
docker run -d -p 1080:1080 -p 10443:10443 -e HTTP_PORT=1080 -e HTTPS_PORT=10443 -v /var/run/docker.sock:/tmp/docker.sock:ro nginxproxy/nginx-proxy
235+
docker run --detach \
236+
--publish 1080:1080 \
237+
--publish 10443:10443 \
238+
--env HTTP_PORT=1080 \
239+
--env HTTPS_PORT=10443 \
240+
--volume /var/run/docker.sock:/tmp/docker.sock:ro \
241+
nginxproxy/nginx-proxy
225242
```
226243

227244
### Multiple Networks
@@ -231,8 +248,12 @@ With the addition of [overlay networking](https://docs.docker.com/engine/usergui
231248
If you want your `nginx-proxy` container to be attached to a different network, you must pass the `--net=my-network` option in your `docker create` or `docker run` command. At the time of this writing, only a single network can be specified at container creation time. To attach to other networks, you can use the `docker network connect` command after your container is created:
232249

233250
```console
234-
docker run -d -p 80:80 -v /var/run/docker.sock:/tmp/docker.sock:ro \
235-
--name my-nginx-proxy --net my-network nginxproxy/nginx-proxy
251+
docker run --detach \
252+
--name my-nginx-proxy \
253+
--publish 80:80 \
254+
--volume /var/run/docker.sock:/tmp/docker.sock:ro \
255+
--net my-network \
256+
nginxproxy/nginx-proxy
236257
docker network connect my-other-network my-nginx-proxy
237258
```
238259

@@ -336,10 +357,12 @@ In order to be able to secure your virtual host, you have to create a file named
336357
`/etc/nginx/htpasswd/`. Example:`/etc/nginx/htpasswd/app.example.com`.
337358

338359
```console
339-
docker run -d -p 80:80 -p 443:443 \
340-
-v /path/to/htpasswd:/etc/nginx/htpasswd \
341-
-v /path/to/certs:/etc/nginx/certs \
342-
-v /var/run/docker.sock:/tmp/docker.sock:ro \
360+
docker run --detach \
361+
--publish 80:80 \
362+
--publish 443:443 \
363+
--volume /path/to/htpasswd:/etc/nginx/htpasswd \
364+
--volume /path/to/certs:/etc/nginx/certs \
365+
--volume /var/run/docker.sock:/tmp/docker.sock:ro \
343366
nginxproxy/nginx-proxy
344367
```
345368

@@ -399,10 +422,10 @@ To remove colors from the container log output, set the [`NO_COLOR` environment
399422

400423
```console
401424
docker run --detach \
402-
--publish 80:80 \
403-
--env NO_COLOR=1 \
404-
--volume /var/run/docker.sock:/tmp/docker.sock:ro \
405-
nginxproxy/nginx-proxy
425+
--publish 80:80 \
426+
--env NO_COLOR=1 \
427+
--volume /var/run/docker.sock:/tmp/docker.sock:ro \
428+
nginxproxy/nginx-proxy
406429
```
407430

408431
⬆️[back to table of contents](#table-of-contents)
@@ -414,7 +437,12 @@ SSL is supported using single host, wildcard and SAN certificates using naming c
414437
To enable SSL:
415438

416439
```console
417-
docker run -d -p 80:80 -p 443:443 -v /path/to/certs:/etc/nginx/certs -v /var/run/docker.sock:/tmp/docker.sock:ro nginxproxy/nginx-proxy
440+
docker run --detach \
441+
--publish 80:80 \
442+
--publish 443:443 \
443+
--volume /path/to/certs:/etc/nginx/certs \
444+
--volume /var/run/docker.sock:/tmp/docker.sock:ro \
445+
nginxproxy/nginx-proxy
418446
```
419447

420448
The contents of`/path/to/certs` should contain the certificates and private keys for any virtual hosts in use. The certificate and keys should be named after the virtual host with a`.crt` and`.key` extension. For example, a container with`VIRTUAL_HOST=foo.bar.com` should have a`foo.bar.com.crt` and`foo.bar.com.key` file in the certs directory.
@@ -445,7 +473,7 @@ In the separate container setup, no pre-generated key will be available and neit
445473
Set`DHPARAM_SKIP` environment variable to`true` to disable using default Diffie-Hellman parameters. The default value is`false`.
446474

447475
```console
448-
docker run -e DHPARAM_SKIP=true ....
476+
docker run --env DHPARAM_SKIP=true ....
449477
```
450478

451479
###Wildcard Certificates
@@ -661,7 +689,11 @@ IPv4 and IPv6 are never both used at the same time on containers that use both I
661689
By default the nginx-proxy container will only listen on IPv4. To enable listening on IPv6 too, set the`ENABLE_IPV6` environment variable to`true`:
662690

663691
```console
664-
docker run -d -p 80:80 -e ENABLE_IPV6=true -v /var/run/docker.sock:/tmp/docker.sock:ro nginxproxy/nginx-proxy
692+
docker run --detach \
693+
--publish 80:80 \
694+
--env ENABLE_IPV6=true \
695+
--volume /var/run/docker.sock:/tmp/docker.sock:ro \
696+
nginxproxy/nginx-proxy
665697
```
666698

667699
###Scoped IPv6 Resolvers
@@ -694,8 +726,11 @@ More reading on the potential TCP head-of-line blocking issue with HTTP/2: [HTTP
694726
HTTP/3 use the QUIC protocol over UDP (unlike HTTP/1.1 and HTTP/2 which work over TCP), so if you want to use HTTP/3 you'll have to explicitely publish the 443/udp port of the proxy in addition to the 443/tcp port:
695727

696728
```console
697-
docker run -d -p 80:80 -p 443:443/tcp -p 443:443/udp \
698-
-v /var/run/docker.sock:/tmp/docker.sock:ro \
729+
docker run --detach \
730+
--publish 80:80 \
731+
--publish 443:443/tcp \
732+
--publish 443:443/udp \
733+
--volume /var/run/docker.sock:/tmp/docker.sock:ro \
699734
nginxproxy/nginx-proxy
700735
```
701736

@@ -788,12 +823,12 @@ client_max_body_size 100m;
788823

789824
```console
790825
docker run --detach \
791-
--name nginx-proxy \
792-
--publish 80:80 \
793-
--publish 443:443 \
794-
--volume /var/run/docker.sock:/tmp/docker.sock:ro \
795-
--volume /path/to/my_proxy.conf:/etc/nginx/conf.d/my_proxy.conf:ro \
796-
nginxproxy/nginx-proxy
826+
--name nginx-proxy \
827+
--publish 80:80 \
828+
--publish 443:443 \
829+
--volume /var/run/docker.sock:/tmp/docker.sock:ro \
830+
--volume /path/to/my_proxy.conf:/etc/nginx/conf.d/my_proxy.conf:ro \
831+
nginxproxy/nginx-proxy
797832
```
798833

799834
</details>
@@ -842,12 +877,12 @@ client_max_body_size 100m;
842877

843878
```console
844879
docker run --detach \
845-
--name nginx-proxy \
846-
--publish 80:80 \
847-
--publish 443:443 \
848-
--volume /var/run/docker.sock:/tmp/docker.sock:ro \
849-
--volume /path/to/custom-vhost-config.conf:/etc/nginx/vhost.d/app.example.com:ro \
850-
nginxproxy/nginx-proxy
880+
--name nginx-proxy \
881+
--publish 80:80 \
882+
--publish 443:443 \
883+
--volume /var/run/docker.sock:/tmp/docker.sock:ro \
884+
--volume /path/to/custom-vhost-config.conf:/etc/nginx/vhost.d/app.example.com:ro \
885+
nginxproxy/nginx-proxy
851886
```
852887

853888
</details>
@@ -877,13 +912,13 @@ If you are using multiple hostnames for a single container (e.g. `VIRTUAL_HOST=e
877912

878913
```console
879914
docker run --detach \
880-
--name nginx-proxy \
881-
--publish 80:80 \
882-
--publish 443:443 \
883-
--volume /path/to/custom-vhost-config.conf:/etc/nginx/vhost.d/example.com:ro \
884-
--volume /path/to/custom-vhost-config.conf:/etc/nginx/vhost.d/www.example.com:ro \
885-
--volume /var/run/docker.sock:/tmp/docker.sock:ro \
886-
nginxproxy/nginx-proxy
915+
--name nginx-proxy \
916+
--publish 80:80 \
917+
--publish 443:443 \
918+
--volume /path/to/custom-vhost-config.conf:/etc/nginx/vhost.d/example.com:ro \
919+
--volume /path/to/custom-vhost-config.conf:/etc/nginx/vhost.d/www.example.com:ro \
920+
--volume /var/run/docker.sock:/tmp/docker.sock:ro \
921+
nginxproxy/nginx-proxy
887922
```
888923

889924
</details>
@@ -933,12 +968,12 @@ proxy_cache_valid 404 1m;
933968

934969
```console
935970
docker run --detach \
936-
--name nginx-proxy \
937-
--publish 80:80 \
938-
--publish 443:443 \
939-
--volume /var/run/docker.sock:/tmp/docker.sock:ro \
940-
--volume /path/to/custom-vhost-location-config.conf:/etc/nginx/vhost.d/app.example.com_location:ro \
941-
nginxproxy/nginx-proxy
971+
--name nginx-proxy \
972+
--publish 80:80 \
973+
--publish 443:443 \
974+
--volume /var/run/docker.sock:/tmp/docker.sock:ro \
975+
--volume /path/to/custom-vhost-location-config.conf:/etc/nginx/vhost.d/app.example.com_location:ro \
976+
nginxproxy/nginx-proxy
942977
```
943978

944979
</details>
@@ -968,13 +1003,13 @@ If you are using multiple hostnames for a single container (e.g. `VIRTUAL_HOST=e
9681003

9691004
```console
9701005
docker run --detach \
971-
--name nginx-proxy \
972-
--publish 80:80 \
973-
--publish 443:443 \
974-
--volume /var/run/docker.sock:/tmp/docker.sock:ro \
975-
--volume /path/to/custom-vhost-location-config.conf:/etc/nginx/vhost.d/example.com_location:ro \
976-
--volume /path/to/custom-vhost-location-config.conf:/etc/nginx/vhost.d/www.example.com_location:ro \
977-
nginxproxy/nginx-proxy
1006+
--name nginx-proxy \
1007+
--publish 80:80 \
1008+
--publish 443:443 \
1009+
--volume /var/run/docker.sock:/tmp/docker.sock:ro \
1010+
--volume /path/to/custom-vhost-location-config.conf:/etc/nginx/vhost.d/example.com_location:ro \
1011+
--volume /path/to/custom-vhost-location-config.conf:/etc/nginx/vhost.d/www.example.com_location:ro \
1012+
nginxproxy/nginx-proxy
9781013
```
9791014

9801015
</details>
@@ -1245,14 +1280,14 @@ Pay attention to the `upstream` definition blocks, which should look like this:
12451280
```nginx
12461281
# foo.example.com
12471282
upstream foo.example.com {
1248-
## Can be connected with "my_network" network
1249-
# Exposed ports: [{ <exposed_port1> tcp } { <exposed_port2> tcp } ...]
1250-
# Default virtual port: <exposed_port|80>
1251-
# VIRTUAL_PORT: <VIRTUAL_PORT>
1252-
# foo
1253-
server 172.18.0.9:<Port>;
1254-
# Fallback entry
1255-
server 127.0.0.1 down;
1283+
## Can be connected with "my_network" network
1284+
# Exposed ports: [{ <exposed_port1> tcp } { <exposed_port2> tcp } ...]
1285+
# Default virtual port: <exposed_port|80>
1286+
# VIRTUAL_PORT: <VIRTUAL_PORT>
1287+
# foo
1288+
server 172.18.0.9:<Port>;
1289+
# Fallback entry
1290+
server 127.0.0.1 down;
12561291
}
12571292
```
12581293

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp