Docker
The fastest way to run Mimic is a single docker run command. The image is around 90 MB compressed and supports both linux/amd64 and linux/arm64.
Minimal run command
Section titled “Minimal run command”docker run -d \ --name mimic \ -p 8080:8080 \ -v $(pwd)/mocks:/app/mocks:ro \ ragilhadi/mimic:latestBreakdown:
-druns the container in the background.--name mimicgives the container a stable name so you candocker stop mimiclater.-p 8080:8080maps host port 8080 to container port 8080.-v $(pwd)/mocks:/app/mocks:romounts your local./mocksfolder into the container as read-only.ragilhadi/mimic:latestis the image. Pin to a specific tag in production.
Mounting on Windows
Section titled “Mounting on Windows”If you’re on Windows, $(pwd) won’t work in cmd or PowerShell. Use the full path or PowerShell’s ${PWD}:
docker run -d ` --name mimic ` -p 8080:8080 ` -v ${PWD}/mocks:/app/mocks:ro ` ragilhadi/mimic:latestRunning on a different port
Section titled “Running on a different port”docker run -d \ --name mimic \ -p 9000:9000 \ -e PORT=9000 \ -v $(pwd)/mocks:/app/mocks:ro \ ragilhadi/mimic:latestBoth the host port mapping and Mimic’s internal port need to change. See Environment Variables.
Health checks
Section titled “Health checks”Mimic exposes a /health endpoint. Use it for Docker’s built-in health check:
docker run -d \ --name mimic \ -p 8080:8080 \ -v $(pwd)/mocks:/app/mocks:ro \ --health-cmd="wget --spider -q http://localhost:8080/health || exit 1" \ --health-interval=10s \ --health-timeout=3s \ --health-retries=3 \ ragilhadi/mimic:latestwget is included in the image specifically so the health check can run inside the container without extra installs.
Managing the container
Section titled “Managing the container”# View logsdocker logs -f mimic
# Restartdocker restart mimic
# Stop and removedocker stop mimic && docker rm mimic
# Pull a newer versiondocker pull ragilhadi/mimic:latestdocker stop mimic && docker rm mimic# (then run again with the same command)Pinning to a version
Section titled “Pinning to a version”docker pull ragilhadi/mimic:v1.0.0docker run -d --name mimic ragilhadi/mimic:v1.0.0Browse available tags on the Docker Hub page.
Where to next
Section titled “Where to next”- For multi-service setups or anything more than a one-liner, use Docker Compose instead.
- For setting log levels and ports, see Environment Variables.