- FIRST ensure you have the latest version
docker pull jamesdbloom/mockserver
- EITHER run the container with no log output (i.e. in daemon mode)
docker run -d --name mockserver -p <serverPort>:1080 -p <proxyPort>:1090 jamesdbloom/mockserver
- OR run the container with log output to console (i.e. in the foreground)
docker run --name mockserver -p <serverPort>:1080 -p <proxyPort>:1090 jamesdbloom/mockserver
- THEN when your finished stop the container
docker stop mockserver && docker rm mockserver
- DEBUG any issues or change the command line options you can run the container with a shell prompt
docker run -i -t --name mockserver -p 1080:1080 -p 1090:1090 jamesdbloom/mockserver /bin/bash
The default command executed when the container runs is:
/opt/mockserver/run_mockserver.sh -logLevel INFO -serverPort 1080 -proxyPort 1090
This can be modified to change the command line options passed to the
/opt/mockserver/run_mockserver.sh script, which supports the following options:
run_mockserver.sh [-logLevel <level>] [-serverPort <port>] [-proxyPort <port>] \ [-proxyRemotePort <port>] [-proxyRemoteHost <hostname>] valid options are: -logLevel <level> OFF, ERROR, WARN, INFO, DEBUG, TRACE or ALL as follows: WARN - exceptions and errors INFO - all interactions -serverPort <port> Specifies the HTTP, HTTPS, SOCKS and HTTP CONNECT port(s) for proxy. Port unification supports for all protocols on the same port(s) -proxyPort <port> Specifies the HTTP and HTTPS port for the MockServer. Port unification is used to support HTTP and HTTPS on the same port -proxyRemotePort <port> Specifies the port to forward all proxy requests to (i.e. all requests received on portPort). This setting is used to enable the port forwarding mode therefore this option disables the HTTP, HTTPS, SOCKS and HTTP CONNECT support -proxyRemoteHost <hostname> Specified the host to forward all proxy requests to (i.e. all requests received on portPort). This setting is ignored unless proxyRemotePort has been specified. If no value is provided for proxyRemoteHost when proxyRemotePort has been specified, proxyRemoteHost will default to "localhost". i.e. run_mockserver.sh -logLevel INFO -serverPort 1080,1081 -proxyPort 1090 \ -proxyRemotePort 80 -proxyRemoteHost www.mock-server.com
logLevel can also be modified by passing environment variable through docker-compose.yml file. The following is a sample docker-compose.yml file for changing logLevel:
mockServer: image: jamesdbloom/mockserver:latest ports: - 1080:1080 environment: - LOG_LEVEL=WARN
LOG_LEVEL value is passed in docker-compose, the default value will be
INFO unless you run the container with other logLevel value on command line.
What is MockServer
MockServer is for mocking of any system you integrate with via HTTP or HTTPS (i.e. services, web sites, etc).
- mocking of any HTTP / HTTPS response when any request is matched (learn more)
- recording requests and responses to analyse how a system behaves (learn more)
- verifying which requests and responses have been sent as part of a test (learn more)
This docker container will run an instance of the MockServer on the following ports:
- serverPort 1080
- proxyPort 1090
For information on how to use the MockServer please see http://www.mock-server.com
If you have any problems, please check the project issues.
Pull requests are, of course, very welcome! Please read our contributing to the project guide first. Then head over to the open issues to see what we need help with. Make sure you let us know if you intend to work on something. Also, check out the milestones to see what is planned for future releases.