Docker Ports Mapping

Author:

Docker Ports Mapping

Task :

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:alpine docker image on Application Server 1.

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

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

Solution :

[root@stapp01 tony]# docker pull nginx:alpine
alpine: Pulling from library/nginx
540db60ca938: Pull complete 
197dc8475a23: Pull complete 
39ea657007e5: Pull complete 
37afbf7d4c3d: Pull complete 
0c01f42c3df7: Pull complete 
d590d87c9181: Pull complete 
Digest: sha256:07ab71a2c8e4ecb19a5a5abcfb3a4f175946c001c8af288b1aa766d67b0d05d2
Status: Downloaded newer image for nginx:alpine
docker.io/library/nginx:alpine
[root@stapp01 tony]# docker container run -d --name blog -p 6100:80 nginx:alpine
d12db2b92b00ff49b7032e5628e17a4ac3a34ce8a60be77154f9b2703d10f7ce
[root@stapp01 tony]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
d12db2b92b00 nginx:alpine "/docker-entrypoint.…" 7 seconds ago Up 5 seconds 0.0.0.0:6100->80/tcp blog
[root@stapp01 tony]# curl http://localhost:6100/
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
body {
width: 35em;
margin: 0 auto;
font-family: Tahoma, Verdana, Arial, sans-serif;
}
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p>

<p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p>

<p><em>Thank you for using nginx.</em></p>
</body>
</html>
[root@stapp01 tony]#

Leave a Reply

Your email address will not be published. Required fields are marked *