How to Create Ubuntu Container with port exposed so that other person can use the container

Hi Am new to Docker and seeking help here.

I want to create a container with Ubuntu and expose a port to end user. So that other person can access the container through putty using some IP:port

I have downloaded image using docker pull ubuntu

And tried creating container using docker run -it - d -p 88:8000 ubuntu

And, when tried docker ps, this is what i got
CONTAINER ID IMAGE COMMAND PORTS NAMES
e9c14f2cfd8b ubuntu “/bin/bash” 0.0.0.0:88->8000/tcp ubuntutest

i did docker inspect container_id, found an IP 172.17.0.6. Hence tried in browser as 172.17.0.6:88 also localhost:88 but both failed to load. In putty also i tried to connect but connection failed.

Any help is highly appreciated.

Thanks in Advance.

expose is a documentation thing… there still has to be an application IN the container configured to LISTEN on the exposed port… it doesn’t happen automagically.

so, you would have to reconfigure the server putty talks to to listen on the exposed port 8000 (the container port)
the syntax for -p is HOST_PORT**:**CONTAINER_PORT
the expose is used to map the container port (8000 is seems in this example) to a HOST system port (88). .

-p 88:8000

means take requests to the host port (88) and send them to the containers port (8000)
http://localhost:88 will send requests to the container on port 8000

you can still talk DIRECTLY to the container port like this

http://172.17.0.6:8000

in ALL cases, there must be an application inside the container listening on port 8000 for it to work.

(you do NOT need to expose to allow direct access to the containers port)