Skip to content

Environment Variables

Mimic is configured entirely through environment variables. There are only two.

The TCP port Mimic listens on.

  • Type: integer
  • Default: 8080
  • Example: PORT=9000

When you change PORT, you also need to update the Docker port mapping. For example, to run Mimic on port 9000:

Terminal window
docker run -d \
--name mimic \
-p 9000:9000 \
-e PORT=9000 \
-v $(pwd)/mocks:/app/mocks:ro \
ragilhadi/mimic:latest

Controls log verbosity.

  • Type: string
  • Default: info
  • Allowed values: trace, debug, info, warn, error
LevelWhen to use
errorProduction. Logs only real errors.
warnProduction with a bit more context.
infoDefault. Logs requests and major events.
debugLocal development and rule debugging. Shows match scoring and reload events.
traceDeep debugging. Very verbose.

debug is particularly useful when figuring out why a specific mock is or isn’t being selected. See Match Priority for what those logs look like.

Pass each variable with -e:

Terminal window
docker run -d \
--name mimic \
-p 8080:8080 \
-e PORT=8080 \
-e RUST_LOG=info \
-v $(pwd)/mocks:/app/mocks:ro \
ragilhadi/mimic:latest

Use the environment block:

services:
mimic:
image: ragilhadi/mimic:latest
environment:
PORT: 8080
RUST_LOG: info

Docker Compose automatically reads a .env file in the same directory as the compose file:

.env
PORT=8080
RUST_LOG=info

Reference the variables in your compose file with ${VAR}:

services:
mimic:
environment:
- PORT=${PORT}
- RUST_LOG=${RUST_LOG}
ports:
- "${PORT}:${PORT}"

If you’re running a locally built binary instead of the Docker image, export the variables in your shell:

Terminal window
export PORT=8080
export RUST_LOG=debug
cargo run --release