为什么不是我的端口暴露? 包括netstat输出

这是我的问题

# docker exec -ti root_web_1 bash [root@ca32f79bdc14]# curl couchdb:5984 curl: (7) Failed to connect to couchdb port 5984: Connection refused [root@ca32f79bdc14]# curl redis:6379 -ERR wrong number of arguments for 'get' command -ERR unknown command 'Host:' -ERR unknown command 'User-Agent:' -ERR unknown command 'Accept:' ^C 

为什么我不能访问couchdb:5984

背景

当我在我的couchdb容器中,我可以curl localhost:5984 ,它响应和netstat -nl给我

 Proto Recv-Q Send-Q Local Address Foreign Address State tcp 0 0 127.0.0.1:5984 0.0.0.0:* LISTEN tcp 0 0 127.0.0.11:35300 0.0.0.0:* LISTEN udp 0 0 127.0.0.11:51267 0.0.0.0:* 

并且Dockerfile包含EXPOSE 5984 ,但在web容器中执行curl couchdb:5984时, connection refused

当我对redis做同样的处理时, curl redis:6379响应, netstat -nl给出

 Proto Recv-Q Send-Q Local Address Foreign Address State tcp 0 0 127.0.0.11:46665 0.0.0.0:* LISTEN tcp 0 0 0.0.0.0:6379 0.0.0.0:* LISTEN tcp6 0 0 :::6379 :::* LISTEN udp 0 0 127.0.0.11:49518 0.0.0.0:* 

这是couchdb Dockerfile

 FROM fedora:25 RUN dnf -y update RUN dnf -y install couchdb EXPOSE 5984 CMD ["/usr/bin/couchdb"] 

这是docker-compose.yml

 version: '2' networks: revproxynet: external: true services: web: images: nginx networks: - revproxynet redis: image: redis networks: - revproxynet couchdb: build: /docker/couchdb/ networks: - revproxynet 

networking创build与docker network create revproxynet

/etc/couchdb/local.ini你需要有

 [httpd] bind_address = 0.0.0.0 

它会工作。