Closed rolele closed 8 years ago
Ports that are published for services don't show up in docker ps
, or docker inspect
for individual containers, because the individual container's ports are not published directly, but published through the built in load balancer.
You can see that the port is published for the service if you docker service inspect <service name>
Note that EXPOSE
is only used if you -P
(capital "p"), to automatically publish all exposed ports, but not required if you explicitly publish a specific port (-p <port>:<port>
)
thanks @thaJeztah
I tried docker service inspect <service name>
and I could see that 9092 is exposed by the service.
Can you tell me why all my other services have a PORTS display during docker ps
but not the kafka service ( I am talking about the PORTS column of docker ps)
root@manager0 vagrant]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
bcdd4c7b3a7c wurstmeister/kafka:latest "start-kafka.sh" 2 minutes ago Up 2 minutes kafka.1.6d3hpnvywytaidsfveuduu4n1
6c872105a1da aaaaaaaa/scrapy-alpine:latest "scrapyd" About an hour ago Up About an hour 6800/tcp scrapy_container.0.6vejpjs9z8nbwt8woxv4nhct7
8aede78ca618 uifd/ui-for-docker:latest "/ui-for-docker" 5 hours ago Up 5 hours 9000/tcp docker-ui.0.cwtszj4g5fvmln5lwm76ocxpk
I am using the exact same principale to start my other services.
that's the way docker ps
shows containers that have an EXPOSE
, so only "informational", but there's no functional difference
I understand. thanks
FWIW, this is on our radar; we do want to improve this as we understand it's a bit confusing
I am using this docker image: https://github.com/wurstmeister/kafka-docker
I noticed that there is no EXPOSE command in the Dockerfile
creating the service using docker service
will result in the service without binding on port 9092
I have never experienced this with standalone docker. Am I missing something?