1-环境配置 - docker配置httpbin项目

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)
posted @ 2020-01-08 18:10  听雨危楼  阅读(1536)  评论(0编辑  收藏  举报