Improve explanation on how to customize nginx conf

When I first saw this document, I didn't understand the meaning of 'This can also be accomplished' and it confused me. 
So, I suggest an improvement.
This commit is contained in:
Daisuke Kashiwagi 2023-09-20 01:40:58 +09:00 committed by DQNEO
parent 1ef03ad7a2
commit 2e359a47de
1 changed files with 14 additions and 8 deletions

View File

@ -35,15 +35,11 @@ $ docker run --name some-nginx -d -p 8080:80 some-content-nginx
Then you can hit `http://localhost:8080` or `http://host-ip:8080` in your browser. Then you can hit `http://localhost:8080` or `http://host-ip:8080` in your browser.
## Complex configuration ## Customize configuration
```console You can mount your configuration file, or build a new image with it.
$ docker run --name my-custom-nginx-container -v /host/path/nginx.conf:/etc/nginx/nginx.conf:ro -d %%IMAGE%%
```
For information on the syntax of the nginx configuration files, see [the official documentation](http://nginx.org/en/docs/) (specifically the [Beginner's Guide](http://nginx.org/en/docs/beginners_guide.html#conf_structure)). If you wish to adapt the default configuration, use something like the following to get it from a running nginx container:
If you wish to adapt the default configuration, use something like the following to copy it from a running nginx container:
```console ```console
$ docker run --name tmp-nginx-container -d %%IMAGE%% $ docker run --name tmp-nginx-container -d %%IMAGE%%
@ -51,7 +47,17 @@ $ docker cp tmp-nginx-container:/etc/nginx/nginx.conf /host/path/nginx.conf
$ docker rm -f tmp-nginx-container $ docker rm -f tmp-nginx-container
``` ```
This can also be accomplished more cleanly using a simple `Dockerfile` (in `/host/path/`): And then edit `/host/path/nginx.conf` in your host file system.
For information on the syntax of the nginx configuration files, see [the official documentation](http://nginx.org/en/docs/) (specifically the [Beginner's Guide](http://nginx.org/en/docs/beginners_guide.html#conf_structure)).
### Mount your configuration file
```console
$ docker run --name my-custom-nginx-container -v /host/path/nginx.conf:/etc/nginx/nginx.conf:ro -d %%IMAGE%%
```
### Build a new image with your configuration file
```dockerfile ```dockerfile
FROM %%IMAGE%% FROM %%IMAGE%%