Skip to main content

Docker

Do you run your apps locally in Docker containers? proxymock works great with local containers, with a bit of configuration.

Choose your adventure below.

Docker Run

Run proxymock locally while your app runs in a container.

  1. Start by running proxymock:
proxymock record --app-port 8080
  1. Pass proxy environment variables to your container when you run it:
docker run \
-e http_proxy=http://host.docker.internal:4140 \
-e https_proxy=http://host.docker.internal:4140 \
your-app:tag \
-p 8080:8080

Requests made to local port 4143 will be recorded as inbound traffic and forwarded to local port 8080, assuming your app listens on port 8080 like our example here. Requests from your app will be forwarded through proxymock and recorded as outbound traffic.

Docker Compose

For complex setups with multiple services, run proxymock alongside your application containers using Docker Compose.

  1. Create or modify your docker-compose.yaml file:
networks:
# put all services on the same network
proxymock-net:
driver: bridge

services:
# proxymock app container
proxymock:
image: gcr.io/speedscale/proxymock:latest
command:
- record
# inbound requests to proxymock port 4143 will be recorded and forwarded to this port
- --app-port
- "8080"
# inbound requests to proxymock port 4143 will be recorded and forwarded to this host
- --app-host
- "app"
# uncomment for verbose logging
#- -vv
ports:
# expose inbound port so you can capture inbound traffic by making requests to this port directly
- "4143:4143"
# expose outbound proxy port in case you need to record apps outside of docker
- "4140:4140"
volumes:
# ensure recorded traffic ends up in a local directory
- ./proxymock:/proxymock
# mount Speedscale config for credentials
- ~/.speedscale/config.yaml:/home/speedscale/.speedscale/config.yaml:ro
# mount certs directory for TLS
- ~/.speedscale/certs:/home/speedscale/.speedscale/certs:ro
networks:
- proxymock-net
environment:
SPEEDSCALE_HOME: /home/speedscale/.speedscale

# your app container
app:
environment:
- http_proxy=http://proxymock:4140
- https_proxy=http://proxymock:4140
# trust the proxymock certificate for HTTPS traffic
- SSL_CERT_FILE=/certs/tls.crt
volumes:
# mount certs from local Speedscale dir
- ~/.speedscale/certs:/certs:ro
depends_on:
- proxymock
networks:
- proxymock-net
############################################################
### everything below is YOUR app-specific configuration! ###
### image, ports, volumes, etc. ###
############################################################
image: your-app:image
ports:
- "8080:8080"
  1. Run docker compose up to start the containers.

  2. Make requests to your app.

Requests made to local port 4143 will be recorded as inbound traffic and forwarded to local port 8080, assuming your app listens on port 8080 like our example here. Requests from your app will be forwarded through proxymock and recorded as outbound traffic. Recorded traffic will be written to the local ./proxymock directory.