似乎无法将docker容器端口暴露给主机

时间:2017-05-13 14:45:38

标签: elasticsearch docker

我可能会遗漏一些荒谬的东西,但我试图暴露给我的主机(Mac)的每个docker容器似乎都不起作用。我可以说容器正在运行并且似乎已经正确地暴露在我选择的端口中。我错过了一些明显的东西吗任何帮助将不胜感激。

我删除了最新的ElasticSearch图片:https://www.elastic.co/guide/en/elasticsearch/reference/current/docker.html

运行Docker: docker run -d -p 9200:9200 docker.elastic.co/elasticsearch/elasticsearch:5.4.0

请求查看正在运行的图片: docker ps

查看正在运行的图片 5e8ae3b13f7c docker.elastic.co/elasticsearch/elasticsearch:5.4.0“/ bin / bash bin / es -...”4秒前Up 4秒0.0.0.0:9200->9200/tcp,9300 / tcp eloquent_almeida < / p>

运行lsof以查看是否有任何在端口9200上暴露的内容 lsof -i tcp:9200

没有返回

Mac OS :10.12.4

Docker更新版本:

docker version
Client:
 Version:      17.04.0-ce
 API version:  1.27 (downgraded from 1.28)
 Go version:   go1.7.5
 Git commit:   4845c56
 Built:        Wed Apr  5 23:33:17 2017
 OS/Arch:      darwin/amd64

Server:
 Version:      17.03.1-ce
 API version:  1.27 (minimum version 1.12)
 Go version:   go1.7.5
 Git commit:   c6d412e
 Built:        Mon Mar 27 16:58:30 2017
 OS/Arch:      linux/amd64
 Experimental: false

下载了nmap并针对9200 localhost运行。还要确保9200现在在/etc/pf.conf中打开。

Nmap scan report for localhost (127.0.0.1)
Host is up (0.00016s latency).
Other addresses for localhost (not scanned): ::1
PORT     STATE  SERVICE
9200/tcp closed wap-wsp

还尝试在mac的IP上使用docker-machine:

docker-machine ip default
192.168.99.100

Tried 192.168.99.100:9200 and still no luck

1 个答案:

答案 0 :(得分:2)

您知道,下载的图像或泊坞窗安装看起来有问题。我重复了你的步骤 - 一切都很好:

[06:40 PM] borlaze@mac: /tmp $ docker run -d -p 9200:9200 docker.elastic.co/elasticsearch/elasticsearch:5.4.0

[06:41 PM] borlaze@mac: /tmp $ docker ps
CONTAINER ID        IMAGE                                                 COMMAND                  CREATED             STATUS              PORTS                              NAMES
fd05a1fe9b5a        docker.elastic.co/elasticsearch/elasticsearch:5.4.0   "/bin/bash bin/es-..."   9 seconds ago       Up 7 seconds        0.0.0.0:9200->9200/tcp, 9300/tcp   practical_bell

[06:41 PM] borlaze@mac: /tmp $ lsof -i tcp:9200
COMMAND     PID    USER   FD   TYPE             DEVICE SIZE/OFF NODE NAME
com.docke 32108 borlaze   21u  IPv4 0x601aa3189a6fc3e3      0t0  TCP *:wap-wsp (LISTEN)
com.docke 32108 borlaze   22u  IPv6 0x601aa318a167e6cb      0t0  TCP localhost:wap-wsp (LISTEN)

检查OS 10.12.4,docker

[06:45 PM] borlaze@mac: /tmp $ docker version
Client:
 Version:      17.03.1-ce
 API version:  1.27
 Go version:   go1.7.5
 Git commit:   c6d412e
 Built:        Tue Mar 28 00:40:02 2017
 OS/Arch:      darwin/amd64

Server:
 Version:      17.03.1-ce
 API version:  1.27 (minimum version 1.12)
 Go version:   go1.7.5
 Git commit:   c6d412e
 Built:        Fri Mar 24 00:00:50 2017
 OS/Arch:      linux/amd64
 Experimental: true

尝试删除图片并重复。