about
httpbin是一個開源項目,使用Python+Flask編寫,利用它可以測試各種HTTP請求和響應。
官網:http://www.httpbin.org/
github:https://github.com/postmanlabs/httpbin
項目雖好,但是鑒於國內網絡的問題,httpbin的官網可能無法訪問或者很卡,這個時候就需要在本地配置httpbin了。
環境
阿里雲centos + docker
docker的配置參考:https://www.cnblogs.com/Neeo/p/10864123.html#docker
我的docker環境是配置好的,接下來我們簡要來說怎么在docker中配置httbin項目。
docker環境搭建httpbin
參照github上面的兩條命令:
docker pull kennethreitz/httpbin
docker run -p 80:80 kennethreitz/httpbin
- 將項目下載到docker容器中
docker pull kennethreitz/httpbin
# 示例
[root@r ~]# docker pull kennethreitz/httpbin
Using default tag: latest
latest: Pulling from kennethreitz/httpbin
473ede7ed136: Pull complete
c46b5fa4d940: Pull complete
93ae3df89c92: Pull complete
6b1eed27cade: Pull complete
0373952b589d: Pull complete
7b82cd0ee527: Pull complete
a36b2d884a89: Pull complete
Digest: sha256:599fe5e5073102dbb0ee3dbb65f049dab44fa9fc251f6835c9990f8fb196a72b
Status: Downloaded newer image for kennethreitz/httpbin:latest
- 在后台運行
[root@r ~]# docker run -d -p 6001:80 --name httpbin --restart=always kennethreitz/httpbin:latest
宿主機的port是6001,然后映射到docker容器中的httbin監聽的80端口。
測試
訪問遠程服務器的6001端口,OK啦!
歡迎斧正,that's all see also:[本地配置httpbin](https://www.jianshu.com/p/088c17def9fc)