fzwcfuqjkvo5foqu7ts7ls578 hello 31 minutes ago 31 minutes ago
$ docker config rm my-config
Error response from daemon: rpc error: code = 3 desc = config 'my-config' is
in use by the following service: redis
```
6. Remove access to the config from the running `redis` service by updating the
service.
```console
$ docker service update --config-rm my-config redis
```
7. Repeat steps 3 and 4 again, verifying that the service no longer has access
to the config. The container ID is different, because the
`service update` command redeploys the service.
```none
$ docker container exec -it $(docker ps --filter name=redis -q) cat /my-config
cat: can't open '/my-config': No such file or directory
```
8. Stop and remove the service, and remove the config from Docker.
```console
$ docker service rm redis
$ docker config rm my-config
```
### Simple example: Use configs in a Windows service
This is a very simple example which shows how to use configs with a Microsoft
IIS service running on Docker for Windows running Windows containers on
Microsoft Windows 10. It is a naive example that stores the webpage in a config.
This example assumes that you have PowerShell installed.
1. Save the following into a new file `index.html`.
```html
<html lang="en">
<head><title>Hello Docker</title></head>
<body>
<p>Hello Docker! You have deployed a HTML page.</p>
</body>
</html>
```
2. If you have not already done so, initialize or join the swarm.
```powershell
docker swarm init
```
3. Save the `index.html` file as a swarm config named `homepage`.
```powershell
docker config create homepage index.html
```
4. Create an IIS service and grant it access to the `homepage` config.
```powershell
docker service create
--name my-iis
--publish published=8000,target=8000
--config src=homepage,target="\inetpub\wwwroot\index.html"
microsoft/iis:nanoserver
```
5. Access the IIS service at `http://localhost:8000/`. It should serve
the HTML content from the first step.
6. Remove the service and the config.
```powershell
docker service rm my-iis
docker config rm homepage
```
### Example: Use a templated config
To create a configuration in which the content will be generated using a
template engine, use the `--template-driver` parameter and specify the engine
name as its argument. The template will be rendered when container is created.
1. Save the following into a new file `index.html.tmpl`.
```html
<html lang="en">
<head><title>Hello Docker</title></head>
<body>
<p>Hello {{ env "HELLO" }}! I'm service {{ .Service.Name }}.</p>
</body>
</html>
```
2. Save the `index.html.tmpl` file as a swarm config named `homepage`. Provide
parameter `--template-driver` and specify `golang` as template engine.
```console
$ docker config create --template-driver golang homepage index.html.tmpl
```
3. Create a service that runs Nginx and has access to the environment variable
HELLO and to the config.
```console
$ docker service create \
--name hello-template \
--env HELLO="Docker" \
--config source=homepage,target=/usr/share/nginx/html/index.html \
--publish published=3000,target=80 \
nginx:alpine
```
4. Verify that the service is operational: you can reach the Nginx server, and
that the correct output is being served.
```console
$ curl http://0.0.0.0:3000
<html lang="en">
<head><title>Hello Docker</title></head>
<body>
<p>Hello Docker! I'm service hello-template.</p>
</body>
</html>
```
### Advanced example: Use configs with a Nginx service
This example is divided into two parts.
[The first part](#generate-the-site-certificate) is all about generating