Code Monkey home page Code Monkey logo

wiremock-docker's Introduction

Wiremock Docker

Main Nightly Docker Pulls a

WireMock Standalone server Docker image

Supported tags

Latest images

Latest WireMock 2.x images

Deprecated tags

  • 3x- Latest WireMock 3.x image, with bundled Java 11 - now latest
  • 3x-alpine - Latest WireMock alpine 3.x image, with bundled Java 11 - now latest

Complete list

Tags

Supported architectures

  • x64
  • armv7
  • armv8

The image includes

  • EXPOSE 8080 8443 : the wiremock http/https server port

How to use this image

Environment variables

  • uid : the container executor uid, useful to avoid file creation owned by root
  • JAVA_OPTS : for passing any custom options to Java e.g. -Xmx128m

Getting started

Pull latest image
docker pull wiremock/wiremock
Start a Wiremock container
docker run -it --rm -p 8080:8080 wiremock/wiremock

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

Start a Wiremock container with Wiremock arguments

To start with these Wiremock arguments : --https-port 8443 --verbose

docker run -it --rm -p 8443:8443 wiremock/wiremock --https-port 8443 --verbose

Access https://localhost:8443/__admin to check https working

Start record mode using host uid for file creation

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 wiremock-container \
  -p 8080:8080 \
  -v $PWD/test:/home/wiremock \
  -e uid=$(id -u) \
  wiremock/wiremock \
    --proxy-all="http://registry.hub.docker.com" \
    --record-mappings --verbose
curl http://localhost:8080
docker rm -f 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 wiremock-container \
  -p 8080:8080 \
  -v $PWD/test:/home/wiremock \
  -u $(id -u):$(id -g) \
  wiremock/wiremock \
    --proxy-all="http://registry.hub.docker.com" \
    --record-mappings --verbose
curl http://localhost:8080
docker rm -f wiremock-container

Check the created file owner with ls -alR test

Samples

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

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

wiremock-docker's People

Contributors

bbezanson avatar kapishmalik avatar oleg-nenashev avatar rodolpheche avatar tomakehurst avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.