我已经安装了postgres和docker的brew版本。 按照链接https://github.com/DiUS/pact_broker-docker/blob/master/POSTGRESQL.md中的步骤创建一个dockerised pact broker和postgres。
当我运行第一个命令时,容器被创建错误:
docker run --name pactbroker-db -e POSTGRES_PASSWORD=ThePostgresPassword -e POSTGRES_USER=admin -e PGDATA=/var/lib/postgresql/data/pgdata -v /var/lib/postgresql/data:/var/lib/postgresql/data -d postgres
响应:
b8a2007e5dac9554e0ac615147d74467ceb6043dba027a4a21388721cee8f34c
docker: Error response from daemon: Mounts denied:
The path /var/lib/postgresql/data
is not shared from OS X and is not known to Docker.
You can configure shared paths from Docker -> Preferences... -> File Sharing...
以某种方式设法通过删除绑定卷选项绕过第一步:
docker run --name pactbroker-db -e POSTGRES_PASSWORD=ThePostgresPassword -e POSTGRES_USER=admin -e PGDATA=/var/lib/postgresql/data/pgdata -d postgres
在指定的链接中成功执行了2个和3个步骤: (2)连接到容器并通过以下方式执行psql: (3)通过以下方式启动PactBroker容器:
在此之后,尝试使用以下命令来卷曲json:
curl -v -XPUT -H “Content-Type: application/json” -d @/HelloWorldConsumer-HelloWorldProvider.json http://localhost/pacts/provider/HelloWorldProvider/consumer/HelloWorldConsumer/version/1.0
获得以下回复......
Could not resolve host: application
* Closing connection 0
curl: (6) Could not resolve host: application
* Trying ::1...
* connect to ::1 port 80 failed: Connection refused
* Trying 127.0.0.1...
* Connected to localhost (127.0.0.1) port 80 (#1)
> PUT /pacts/provider/HelloWorldProvider/consumer/HelloWorldConsumer/version/1.0 HTTP/1.1
> Host: localhost
> User-Agent: curl/7.49.1
> Accept: */*
> Content-Length: 756
> Content-Type: application/x-www-form-urlencoded
>
* upload completely sent off: 756 out of 756 bytes
< HTTP/1.1 415 Unsupported Media Type
< Content-Type: application/json;charset=utf-8
< Content-Length: 0
< Connection: keep-alive
< Status: 415 Unsupported Media Type
< Date: Tue, 07 Feb 2017 17:08:40 GMT
< Server: Webmachine-Ruby/1.4.0 Rack/1.2
< X-Powered-By: Phusion Passenger 5.0.15
<
* Connection #1 to host localhost left intact
不确定它的成功与否是第一行说的''无法解析主机:应用程序'和'关闭连接'
当我尝试查看localhost时,它显示为空白。 附上截图。 尽早寻求帮助!!提前谢谢......
答案 0 :(得分:0)
您似乎正在尝试在主机上安装一个不存在的卷(/var/lib/postgresql/data
)。
docker: Error response from daemon: Mounts denied:
The path /var/lib/postgresql/data
is not shared from OS X and is not known to Docker.
该消息清楚地表明了这一点。你应该read more关于docker卷,但我建议你安装另一个目录,如果这是用于Mac上的开发。
其次,你可以看到你在上传中获得了“不支持的媒体类型”,所以它肯定失败了:
HTTP/1.1 415 Unsupported Media Type
似乎没有正确设置Content-Type,您可以在输出中看到:
Content-Type: application/x-www-form-urlencoded
请检查文件是否实际存在于路径/HelloWorldConsumer-HelloWorldProvider.json
,它是一个有效的JSON文件,并且您的内容类型标题格式正确(看起来是这样)。