Docker Community Forums

Share and learn in the Docker community.

Expose ports to internet

Hi There,

I’m new to Docker and am trying things out.

My first question is, i have a container running, which has an app running on port 9150

How do i “expose” this so its accessible via the internet ?

I can see its listening on 0.0.0.0:9150

My Host server is Centos7.

I have iptables installed, and have enable masquerading and the docker network is in the public zone.

There is no upstream firewall between the server and the Border gateway.

Any help appreciated !

A

1 Like

If you allready defined -p 9150:9150 (fx.) it should be exposed, and you should be able to access it

1 Like

thanks for your reply!

i have these commands in my yaml file:

ports:
- 5601:5601
expose:
- “5601”

i see the ports in a netstat as listening, but cannot connect from a browser as this is a http server

1 Like

If the image you’re using, is using port 9150, and you want to use port 5601, you need to define the compose section as:

ports:
- 5601:9150

the “expose:” part of your yaml is not needed.

Hope it makes sense else please include your compose file

1 Like

sorry i got that bit wrong…

the container has a http server running on port 9150…

so i expect to go http://ip-address:9150 and the site shows

but it doesnt

thanks again for your responses

1 Like

So you have:

ports:
- 9150:9150

?
again. please share your compose file make it a bit easier to help, ofcourse remove passwords first ^^

1 Like

here you go…

its a test config for a demo of elastic search

the containers start just fine, i just cant access them !

docker-compose.yaml.txt (1.88 KB)

1 Like

Sorry, but im a bit confused, where does port 9150 come from?

Its not listed on here either?

does port 5601 work?

1 Like

9150 was an example port i was trying…

sorry i confused myself !

the web server is on port 5601 as you have deduced !

the port is listening…
tcp 0 0 0.0.0.0:5601 0.0.0.0:* LISTEN

but browsing to it does nothing.

i cannot telnet to it on port 5601 either…

1 Like

Does “docker logs odfe-kibana” give anything?

1 Like

hmmm

notably:

{“type”:“log”,"@timestamp":“2021-04-19T15:45:17Z”,“tags”:[“listening”,“info”],“pid”:1,“message”:“Server running at http://0:5601”}
{“type”:“log”,"@timestamp":“2021-04-19T15:45:17Z”,“tags”:[“info”,“http”,“server”,“Kibana”],“pid”:1,“message”:“http server running at http://0:5601”}

1 Like

When you say you cant telnet/browser to that ip, is that from a different host?
what happends if you try and curl http://127.0.0.1:5601 from the server itself?

1 Like

I was able to see all the images in docker desktop under images. But all of a sudden from yesterday, I can see images with docker images command from CLI, but could not see them on docker desktop.

1 Like