Docker container can't leverage external Cloudant service (network resolution / visibility?)

痞子三分冷 提交于 2019-12-10 17:17:21

问题


I've built a Container that leverages a CF app that's bound to a service, Cloudant to be specific.

When I run the container locally I can connect to my Cloudant service.

When I build and run my image in the Bluemix container service I can no longer connect to my Cloudant service. I did use --bind to bind my app to the container. I have verified that the VCAP_Services info is propagating to my container successfully.

To narrow the problem down further, I tried just doing an

ice -run --name NAME IMAGE_NAME ping CLOUDANT_HOST

and I found I was getting an unknown host.

So I then tried to just ping the IP, and got Network is unreachable.

If we can not resolve bluemix services over the network, how can we leverage them? Is there just a temporary problem, or perhaps I'm missing something?

Again, runs fine locally but fails when hosted in the container service.


回答1:


It has been my experience that networking is not reliable in IBM Containers for about 5 seconds at startup. Try adding a "sleep 10" to your CMD or ENTRYPOINT. Or set it up to retry for X seconds before giving up.

Once the networking comes up it has been reliable for me. But the first few seconds of a containers life have had troubles with DNS, binding, and outgoing traffic.




回答2:


looking at your problem it could be related to a network error on container when on Bluemix. Try to access your container through shell when on Bluemix (using cf ic console or docker one) and check if the network has been rised correctly and then if its network interface(s) has an IP to use.



来源:https://stackoverflow.com/questions/30310602/docker-container-cant-leverage-external-cloudant-service-network-resolution

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!