Docker Community Forums

Share and learn in the Docker community.

Elastic - sebp/elk - How to run separate, multiple containers on the same host

Setting up different containers of the Elastic stack (sebp-elk) on the same host.
https://hub.docker.com/r/sebp/elk/
https://elk-docker.readthedocs.io/

The first instance runs fine, per the docs, with this command:
sudo docker run --ulimit nofile=65536:65536 -p 5601:5601 -p 9200:9200 -p 5044:5044 -it --name Dev sebp/elk

Attempts to run a second container with different ports does not work:
sudo docker run --ulimit nofile=65536:65536 -p 5617:5617 -p 9217:9217 -p 9317:9317 -p 5017:5017 -it --name Miklas sebp/elk

a sudo docker ps shows this:
5044/tcp, 0.0.0.0:5017->5017/tcp, 5601/tcp, 0.0.0.0:5617->5617/tcp, 9200/tcp, 0.0.0.0:9217->9217/tcp, 0.0.0.0:9317->9317/tcp, 9300/tcp
… not sure why we have ports 5044/tcp, 5601/tcp, and 9200/tcp, and 9300/tcp when I set them differently.

How can I run separate containers of this image on the same host without conflicts? Thx Keith :^)

Of course this does not work. While your first docker run statements uses the correct container port (the right hand side of the port mapping), the second run statements uses phoney container ports. A port mapping itself will neither have affect on the applications inside the container, nor will it verify that a process is actualy listening on the port.

You need to set the host side (the left hand side of the port mapping!), while using the documentent container ports to create useful mappings:

sudo docker run --ulimit nofile=65536:65536 -p 5617:5601 -p 9217:9200 -p 9317:9300 -p 5017:5044 -it --name Miklas sebp/elk

Anyway, make sure to follow the docs to use the image like it is intended.