Skip to content

Commit

Permalink
Merge pull request nginx-proxy#772 from nginx-proxy/doc-volume
Browse files Browse the repository at this point in the history
Update volume-related docs and examples
  • Loading branch information
buchdag authored Mar 26, 2021
2 parents 3a037b3 + a5e3b3b commit 53d2ac1
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 35 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ $ docker run --detach \
--name nginx-proxy \
--publish 80:80 \
--publish 443:443 \
--volume /etc/nginx/certs \
--volume /etc/nginx/vhost.d \
--volume /usr/share/nginx/html \
--volume certs:/etc/nginx/certs \
--volume vhost:/etc/nginx/vhost.d \
--volume html:/usr/share/nginx/html \
--volume /var/run/docker.sock:/tmp/docker.sock:ro \
jwilder/nginx-proxy
```
Expand All @@ -69,7 +69,7 @@ $ docker run --detach \
--name nginx-proxy-letsencrypt \
--volumes-from nginx-proxy \
--volume /var/run/docker.sock:/var/run/docker.sock:ro \
--volume /etc/acme.sh \
--volume acme:/etc/acme.sh \
--env "[email protected]" \
jrcs/letsencrypt-nginx-proxy-companion
```
Expand Down
10 changes: 5 additions & 5 deletions docs/Advanced-usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ $ docker run --detach \
--publish 80:80 \
--publish 443:443 \
--name nginx \
--volume /etc/nginx/conf.d \
--volume /etc/nginx/vhost.d \
--volume /usr/share/nginx/html \
--volume /etc/nginx/certs \
--volume conf:/etc/nginx/conf.d \
--volume vhost:/etc/nginx/vhost.d \
--volume html:/usr/share/nginx/html \
--volume certs:/etc/nginx/certs \
nginx
```

Expand Down Expand Up @@ -61,7 +61,7 @@ $ docker run --detach \
--name nginx-proxy-letsencrypt \
--volumes-from nginx-proxy \
--volume /var/run/docker.sock:/var/run/docker.sock:ro \
--volume /etc/acme.sh \
--volume acme:/etc/acme.sh \
--env "NGINX_DOCKER_GEN_CONTAINER=nginx-proxy-gen" \
--env "[email protected]" \
jrcs/letsencrypt-nginx-proxy-companion
Expand Down
8 changes: 4 additions & 4 deletions docs/Basic-usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ $ docker run --detach \
--name nginx-proxy \
--publish 80:80 \
--publish 443:443 \
--volume /etc/nginx/certs \
--volume /etc/nginx/vhost.d \
--volume /usr/share/nginx/html \
--volume certs:/etc/nginx/certs \
--volume vhost:/etc/nginx/vhost.d \
--volume html:/usr/share/nginx/html \
--volume /var/run/docker.sock:/tmp/docker.sock:ro \
jwilder/nginx-proxy
```
Expand All @@ -39,7 +39,7 @@ $ docker run --detach \
--name nginx-proxy-letsencrypt \
--volumes-from nginx-proxy \
--volume /var/run/docker.sock:/var/run/docker.sock:ro \
--volume /etc/acme.sh \
--volume acme:/etc/acme.sh \
--env "[email protected]" \
jrcs/letsencrypt-nginx-proxy-companion
```
Expand Down
3 changes: 2 additions & 1 deletion docs/Container-configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ For example
$ docker run --detach \
--name nginx-proxy-letsencrypt \
--volumes-from nginx-proxy \
--volume /path/to/certs:/etc/nginx/certs:rw \
--volume /var/run/docker.sock:/var/run/docker.sock:ro \
--volume certs:/etc/nginx/certs:rw \
--volume acme:/etc/acme.sh \
--env "ACME_CA_URI=https://acme-staging-v02.api.letsencrypt.org/directory" \
jrcs/letsencrypt-nginx-proxy-companion
```
Expand Down
33 changes: 16 additions & 17 deletions docs/Persistent-data.md
Original file line number Diff line number Diff line change
@@ -1,48 +1,47 @@
## Persistent data

### Anonymous volumes
### Named volumes (recommended)

When you follow instructions from Basic usage or Advanced usage, Docker will automatically create **anonymous volumes** (volumes with a random name) for every `--volume` / `-v` argument passed:
When you follow instructions from Basic usage or Advanced usage, Docker will automatically create **named volumes** for every `--volume` / `-v` argument passed. Named volume will make it easy for you to mount the same persisted data even if you delete then re-create the container:

```shell
$ docker run -d \
--name nginx-proxy \
-p 80:80 \
-p 443:443 \
-v /etc/nginx/certs \
-v /etc/nginx/vhost.d \
-v /usr/share/nginx/html \
-v certs:/etc/nginx/certs \
-v vhost:/etc/nginx/vhost.d \
-v html:/usr/share/nginx/html \
-v /var/run/docker.sock:/tmp/docker.sock:ro \
jwilder/nginx-proxy

$ docker volume ls
DRIVER VOLUME NAME
local 287be3abd610e5566500d719ceb8b952952f12c9324ef02d05785d4ee9737ae9
local 6530b1b40cf89efb71aa7fd19bddec927fa2bcae59b04b9c1c850af72ffe0123
local f260f71fefadcdfc311d285d69151f2312915174d3fb1fab89949ec5ec871a54
local f2cd94ca48904dc9cfc840ce4b265a04831c580d525253d7a0e5aac4d1dca340
local certs
local vhost
local html
```

### Named volumes (recommended)
### Anonymous volumes (not recommended)

Using **named volumes** instead make managing volumes easier:
If you don't prefix your volumes with a name, Docker will instead create **anonymous volumes** (volumes with a random name). Those volume persist after the container is deleted but aren't automatically re-mounted when you re-create the container. Their usage is **not recommended** as they don't provide any advantages over named volumes and make keeping tracks of what volume store which data way harder.

```shell
$ docker run -d \
--name nginx-proxy \
-p 80:80 \
-p 443:443 \
-v certs:/etc/nginx/certs \
-v vhost:/etc/nginx/vhost.d \
-v html:/usr/share/nginx/html \
-v /etc/nginx/certs \
-v /etc/nginx/vhost.d \
-v /usr/share/nginx/html \
-v /var/run/docker.sock:/tmp/docker.sock:ro \
jwilder/nginx-proxy

$ docker volume ls
DRIVER VOLUME NAME
local certs
local vhost
local html
local 287be3abd610e5566500d719ceb8b952952f12c9324ef02d05785d4ee9737ae9
local 6530b1b40cf89efb71aa7fd19bddec927fa2bcae59b04b9c1c850af72ffe0123
local f260f71fefadcdfc311d285d69151f2312915174d3fb1fab89949ec5ec871a54
```

### Host volumes
Expand Down
9 changes: 5 additions & 4 deletions docs/Standalone-certificates.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ $ docker run --detach \
--name nginx-proxy \
--publish 80:80 \
--publish 443:443 \
--volume /etc/nginx/certs \
--volume /etc/nginx/vhost.d \
--volume /etc/nginx/conf.d \
--volume /usr/share/nginx/html \
--volume certs:/etc/nginx/certs \
--volume vhost:/etc/nginx/vhost.d \
--volume conf:/etc/nginx/conf.d \
--volume html:/usr/share/nginx/html \
--volume /var/run/docker.sock:/tmp/docker.sock:ro \
jwilder/nginx-proxy
```
Expand All @@ -19,6 +19,7 @@ $ docker run --detach \
--name nginx-proxy-letsencrypt \
--volumes-from nginx-proxy \
--volume /var/run/docker.sock:/var/run/docker.sock:ro \
--volume acme:/etc/acme.sh \
--volume /path/to/your/config_file:/app/letsencrypt_user_data:ro \
jrcs/letsencrypt-nginx-proxy-companion
```
Expand Down

0 comments on commit 53d2ac1

Please sign in to comment.