我正在开发一个服务,并使用docker compose来旋转postgres,redis,elasticsearch等服务.我有一个基于RubyOnRails的Web应用程序,可以从所有这些服务中进行写入和读取.
这是我的 docker-compose.yml
version: '2'
services:
redis:
image: redis:2.8
networks:
- frontapp
elasticsearch:
image: elasticsearch:2.2
networks:
- frontapp
postgres:
image: postgres:9.5
environment:
POSTGRES_USER: elephant
POSTGRES_PASSWORD: smarty_pants
POSTGRES_DB: elephant
volumes:
- /var/lib/postgresql/data
networks:
- frontapp
networks:
frontapp:
driver: bridge
Run Code Online (Sandbox Code Playgroud)
我可以ping这个网络中的容器
$ docker-compose run redis /bin/bash
root@777501e06c03:/data# ping postgres
PING postgres (172.20.0.2): 56 data bytes
64 bytes from 172.20.0.2: icmp_seq=0 ttl=64 time=0.346 ms
64 bytes from 172.20.0.2: icmp_seq=1 ttl=64 time=0.047 ms
...
Run Code Online (Sandbox Code Playgroud)
到现在为止还挺好.现在我想在我的主机上的rails应用程序上运行ruby但是能够使用url访问postgres实例,就像postgresql://username:password@postgres/database目前那样是不可能的
$ ping postgres
ping: unknown host …Run Code Online (Sandbox Code Playgroud) 经过相当长的一段时间,使用他们的API V3向Github发布私人要点后,我几乎放弃了.几乎.也许有些人也遇到过类似问题或者知道可能是以下行为的原因:
现在curl命令如下所示:
curl -H "Authorization: bearer MY_AUTHORIZATION_TOKE" -H "Accept: application/json" -H "Content-type: application/json" -X POST -d '{"public":false,"files":{"test.txt":{"content":"String file contents"}}}' https://api.github.com/gists
Run Code Online (Sandbox Code Playgroud)
我也试过了
curl -H "Authorization: bearer MY_AUTHORIZATION_TOKE" -X POST -d '{"public":false,"files":{"test.txt":{"content":"String file contents"}}}' https://api.github.com/gists
Run Code Online (Sandbox Code Playgroud)
我可以使用完全相同的数据创建没有授权令牌的gist:
curl -X POST -d '{"public":true,"files":{"test.txt":{"content":"String file contents"}}}' https://api.github.com/gists
Run Code Online (Sandbox Code Playgroud)
但在这种情况下,它将是匿名的
如果我想将其公之于众,那么结果相同
无论如何,Github都会回来
HTTP/1.1 404 Not Found
{
"message": "Not Found"
}
Run Code Online (Sandbox Code Playgroud)
我很确定我已经获得授权,因为curl -H "Authorization: bearer MY_AUTHORIZATION_TOKE" https://api.github.com/user我将用户详细信息返回给我.
适用范围如下:
https://github.com/login/oauth/authorize?client_id=...&scope=gist
因此,它应该具有读取和写入权限.