Sign inSign up

ppavlov/wiremock

By ppavlov

•Updated about 9 years ago

Wiremock container easy to update versions

Image
0

910

ppavlov/wiremock repository overview

⁠The image includes

  • EXPOSE 8080 8081 : the wiremock http/https server port
  • VOLUME /home/wiremock : the wiremock data storage

⁠How to use this image

⁠Environment variables
  • uid : the container executor uid, useful to avoid file creation owned by root
⁠Getting started
⁠Pull latest image
docker pull ppavlov/wiremock
⁠Start a Wiremock container
docker run -it --rm -p 8080:8080 ppavlov/wiremock

Access http://localhost:8080/__admin⁠ to display the mappings (empty set)

⁠Start a Wiremock container with Wiremock arguments
docker run -it --rm -p 8081:8081 ppavlov/wiremock --https-port 8081 --verbose

Access https://localhost:8081/__admin⁠ to check https working

⁠Start record mode using host uid for file creation

In Record mode, when binding host folders (ex. $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 ppavlov-wiremock-container \
  -p 8080:8080 \
  -v $PWD/test:/home/wiremock \
  -e uid=$(id -u) \
  ppavlov/wiremock \
    --proxy-all="http://registry.hub.docker.com" \
    --record-mappings --verbose
curl http://localhost:8080
docker rm -f ppavlov-wiremock-container

Check the created file owner with ls -alR test

⁠Samples
⁠Start a Hello World container
⁠Inline
git clone https://github.com/pmpavlov/wiremock.git
docker run -it --rm \
  -p 8080:8080 \
  -v $PWD/wiremock-docker/samples/hello/stubs:/home/wiremock \
  ppavlov/wiremock
⁠Dockerfile
git clone https://github.com/ppavlov/wiremock.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

⁠Use wiremock extensions
⁠Inline
git clone https://github.com/ppavlov/wiremock.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 \
  ppavlov/wiremock \
    --extensions com.opentable.extension.BodyTransformer
⁠Dockerfile
git clone https://github.com/ppavlov/wiremock.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

Tag summary

Content type

Image

Digest

Size

292.4 MB

Last updated

about 9 years ago

docker pull ppavlov/wiremock