Run an Image With a Mutable Configuration
This section describes how to add a basic route to your local IG configuration folder, and mount the configuration to the Docker container.
If you change your configuration in a way that doesn't require IG to restart, you see the change in your running Docker image without restarting it or rebuilding it. For information about configuration changes that require restart, see "Changing the Configuration and Restarting IG".
Use this procedure to manage configuration externally to the Docker image. For example, use it when you are developing routes.
Add the following route to your local IG configuration as
$HOME/.openig/config/routes/hello.json
:{ "name": "hello", "handler": { "type": "StaticResponseHandler", "config": { "status": 200, "reason": "OK", "headers": { "Content-Type": [ "text/plain" ] }, "entity": "Hello world!" } }, "condition": "${matches(request.uri.path, '^/hello')}" }
The configuration contains a static response handler to return a "Hello world!" statement when the URI of a request finishes with
/hello
.Run the Docker image, using the option to mount the local IG configuration directory:
$
docker run -p 8080:8080 -v $HOME/.openig:/var/ig/ ig-image
Go to http://localhost:8080/hello to access the route in the mounted configuration.
The "Hello world!" statement is displayed.
Edit
hello.json
to change the "Hello world!" statement, and save the file.Go again to http://localhost:8080/hello to see that the message changed without changing your Docker image.