我有这个docker-compose.yml:
piousbox@Vadims-MacBook-Pro:~/projects/docker/mongo$ cat docker-compose.yml
version: '3'
services:
mongo:
image: 'mongo:4.0.1'
command: mongod --port 27025 --bind_ip_all
ports:
- '27025:27025'
如果将ssh放入容器中,我可以做mongo --port 27025
,但是从主机上我不能,为什么呢?我在Mac 10.13.6上,已禁用防火墙,已启用pfctl但未阻止27025。
答案 0 :(得分:0)
啊!这是因为docker机器的安装方式是拥有自己的ip,而不是localhost:
piousbox@Vadims-MacBook-Pro:~/projects/ruby/CreditNinjaAdmin$ docker-machine env default
export DOCKER_TLS_VERIFY="1"
export DOCKER_HOST="tcp://192.168.99.100:2376"
export DOCKER_CERT_PATH="/Users/piousbox/.docker/machine/machines/default"
export DOCKER_MACHINE_NAME="default"
# Run this command to configure your shell:
# eval $(docker-machine env default)