DEV Community

Janak Shrestha
Janak Shrestha

Posted on

Docker Ports Mapping

The Nautilus DevOps team is planning to host an application on a nginx-based container. There are number of tickets already been created for similar tasks. One of the tickets has been assigned to set up a nginx container on Application Server 1 in Stratos Datacenter. Please perform the task as per details mentioned below:

a. Pull nginx:stable docker image on Application Server 1.

b. Create a container named cluster using the image you pulled.

c. Map host port 8089 to container port 80. Please keep the container in running state.


Connect to App Server 1

ssh tony@stapp01
sudo -i
Enter fullscreen mode Exit fullscreen mode

Password for tony: Ir0nM@n


Pull the nginx:stable Image

docker pull nginx:stable
Enter fullscreen mode Exit fullscreen mode

The image was pulled successfully with digest sha256:a7675fcee220f59b4a99f7098c06a0d5d999c2c0ee37c0211efb780536e5cb20.

Verify the image:

docker images | grep nginx
Enter fullscreen mode Exit fullscreen mode

Output:

nginx        stable    2cbc7a375718   6 days ago   162MB
Enter fullscreen mode Exit fullscreen mode

Create the Container with Port Mapping

docker run -d --name cluster -p 8089:80 nginx:stable
Enter fullscreen mode Exit fullscreen mode

The container was created with ID be82a3c468a5.


Verify the Container is Running

docker ps | grep cluster
Enter fullscreen mode Exit fullscreen mode

Output:

be82a3c468a5   nginx:stable   "/docker-entrypoint.…"   8 seconds ago   Up 7 seconds   0.0.0.0:8089->80/tcp, :::8089->80/tcp   cluster
Enter fullscreen mode Exit fullscreen mode

The container cluster is running and port 8089 is mapped to container port 80.


Verify the Port Mapping

docker port cluster
Enter fullscreen mode Exit fullscreen mode

Output:

80/tcp -> 0.0.0.0:8089
80/tcp -> [::]:8089
Enter fullscreen mode Exit fullscreen mode

Alternative verification:

docker inspect cluster --format='{{range $p, $conf := .NetworkSettings.Ports}}{{$p}} -> {{(index $conf 0).HostPort}}{{end}}'
Enter fullscreen mode Exit fullscreen mode

Output:

80/tcp -> 8089
Enter fullscreen mode Exit fullscreen mode

Test the Port Mapping

curl -I http://localhost:8089/
Enter fullscreen mode Exit fullscreen mode

Output:

HTTP/1.1 200 OK
Server: nginx/1.30.6
Date: Tue, 27 Oct 2026 11:18:14 GMT
Content-Type: text/html
Content-Length: 896
Last-Modified: Fri, 02 Oct 2026 14:33:28 GMT
Connection: keep-alive
ETag: "6abfc0b8-380"
Accept-Ranges: bytes
Enter fullscreen mode Exit fullscreen mode

The HTTP 200 OK response confirms the nginx container is accessible on host port 8089.


Complete Command Sequence

ssh tony@stapp01
sudo -i

docker pull nginx:stable

docker run -d --name cluster -p 8089:80 nginx:stable

docker ps | grep cluster
docker port cluster
curl -I http://localhost:8089/
Enter fullscreen mode Exit fullscreen mode

Top comments (0)