LoginSignup
0
0

Dockerを使ってPrismを指定のポートで立ち上げる

Posted at

Prismを指定のポートで立ち上げようと思った時、スムーズにいかなかったので記事にする。

どうハマったか

Prismを4011番Portでリスンさせたい。

$ docker run --init --rm \
-v $(pwd)/examples/v3.0/api-with-examples.json:/api-with-examples.json \
-p 4011:4011 \
stoplight/prism:4 mock -h 0.0.0.0 "/api-with-examples.json" 

を実行すると、

[3:18:38 AM] › [CLI] ✔  success   Prism is listening on http://0.0.0.0:4010

あれ、、4010でPrismがリスンしている状態になる。

原因

図で説明すると、以下のようになっている。

[ホスト]             [Docker コンテナ]
  |                      |
  |  :4011               |  :4011
  |----->|               |----->| Prism
  |                      |      :4010 (内部ポート)
  |                      |

Prismのポートの指定ができておらず、デフォルトの4010で立ち上がっていた。

解決策

$ docker run --init --rm \
-v $(pwd)/examples/v3.0/api-with-examples.json:/api-with-examples.json \
-p 4011:4011 \
stoplight/prism:4 mock -h 0.0.0.0 -p 4011 "/api-with-examples.json" 

を実行すると、

[3:29:00 AM] › [CLI] ✔  success   Prism is listening on http://0.0.0.0:4011

はい、Prismが4011ポートでリスンしている状態になりました。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0