Wiremock standalone HTTP server Docker image
2.29.0
,latest
(2.29/Dockerfile)2.29.0-alpine
,latest-alpine
(2.29-alpine/Dockerfile)main
(main/Dockerfile)main-alpine
(main-alpine/Dockerfile)nightly
(main/Dockerfile)nightly-alpine
(main-alpine/Dockerfile)
EXPOSE 8080 8443
: the wiremock http/https server portVOLUME /home/wiremock
: the wiremock data storage
uid
: the container executor uid, useful to avoid file creation owned by rootJAVA_OPTS
: for passing any custom options to Java e.g.-Xmx128m
docker pull rodolpheche/wiremock
docker run -it --rm -p 8080:8080 rodolpheche/wiremock
Access http://localhost:8080/__admin to display the mappings (empty set)
To start with these Wiremock arguments : --https-port 8443 --verbose
docker run -it --rm -p 8443:8443 rodolpheche/wiremock --https-port 8443 --verbose
Access https://localhost:8443/__admin to check https working
In Record mode, when binding host folders (e.g. $PWD/test) with the container volume (/home/wiremock), the created files will be owned by root, which is, in most cases, undesired.
To avoid this, you can use the uid
docker environment variable to also bind host uid with the container executor uid.
docker run -d --name rodolpheche-wiremock-container \
-p 8080:8080 \
-v $PWD/test:/home/wiremock \
-e uid=$(id -u) \
rodolpheche/wiremock \
--proxy-all="http://registry.hub.docker.com" \
--record-mappings --verbose
curl http://localhost:8080
docker rm -f rodolpheche-wiremock-container
Check the created file owner with
ls -alR test
However, the example above is a facility. The good practice is to create yourself the binded folder with correct permissions and to use the -u docker argument.
mkdir test
docker run -d --name rodolpheche-wiremock-container \
-p 8080:8080 \
-v $PWD/test:/home/wiremock \
-u $(id -u):$(id -g) \
rodolpheche/wiremock \
--proxy-all="http://registry.hub.docker.com" \
--record-mappings --verbose
curl http://localhost:8080
docker rm -f rodolpheche-wiremock-container
Check the created file owner with
ls -alR test
git clone https://github.com/rodolpheche/wiremock-docker.git
docker run -it --rm \
-p 8080:8080 \
-v $PWD/wiremock-docker/samples/hello/stubs:/home/wiremock \
rodolpheche/wiremock
git clone https://github.com/rodolpheche/wiremock-docker.git
docker build -t wiremock-hello wiremock-docker/samples/hello
docker run -it --rm -p 8080:8080 wiremock-hello
Access http://localhost:8080/hello to show Hello World message
git clone https://github.com/rodolpheche/wiremock-docker.git
# prepare extension folder
mkdir wiremock-docker/samples/random/extensions
# download extension
wget https://repo1.maven.org/maven2/com/opentable/wiremock-body-transformer/1.1.3/wiremock-body-transformer-1.1.3.jar \
-O wiremock-docker/samples/random/extensions/wiremock-body-transformer-1.1.3.jar
# run a container using extension
docker run -it --rm \
-p 8080:8080 \
-v $PWD/wiremock-docker/samples/random/stubs:/home/wiremock \
-v $PWD/wiremock-docker/samples/random/extensions:/var/wiremock/extensions \
rodolpheche/wiremock \
--extensions com.opentable.extension.BodyTransformer
git clone https://github.com/rodolpheche/wiremock-docker.git
docker build -t wiremock-random wiremock-docker/samples/random
docker run -it --rm -p 8080:8080 wiremock-random
Access http://localhost:8080/random to show random number