Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How run stoplight prism mock from docker image

Tags:

docker

mocking

I am trying to run the prism mock server from docker stoplight/prism image, but I didn't find simple documentation to run from volume (not from HTTP external link).

This is my approach: attach the volume with my local API definitions at the local ~/apis directory

@ ~/apis () $ ls
openapi.yml

And run in this way

 $ docker run --rm -v ~/apis:/tmp -t stoplight/prism mock -p 4010 --host 0.0.0.0 /tmp/openapi.yaml 
 [10:16:46 AM] › [CLI] …  awaiting  Starting Prism…
 [10:16:47 AM] › [CLI] ✖  fatal     Error opening file "/tmp/openapi.yaml" 
 ENOENT: no such file or directory, open '/tmp/openapi.yaml'

Edited

After Neo Anderson put me on the right way, I am able to run the mock server in this way :

docker run --rm -v ~/apis:/root/apis -p 9003:4010 -t stoplight/prism mock -h 0.0.0.0 /root/apis/openapi.yml

Watch run docker logs and try the URLs, like this:

http://127.0.0.1:9003/myapi/path...
like image 251
danipenaperez Avatar asked Oct 30 '25 11:10

danipenaperez


1 Answers

You are using *.yml in the volume and .yaml in the docker run command.
You may fix it on either side.
Everything else looks good.

like image 85
Neo Anderson Avatar answered Nov 02 '25 17:11

Neo Anderson