Question : 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 2 in Stratos Datacenter. Please perform the task as per details mentioned below:
a. Pull nginx:stable docker image on Application Server 2.
b. Create a container named apps using the image you pulled.
c. Map host port 8084 to container port 80. Please keep the container in running state.
Please Note :- Perform the below commands based on your question server, user name & other details might differ . So please read task carefully before executing. All the Best 👍
Solution:
1. At first login on app server ssh steve@stapp02
2. Switch to root user : sudo su -
3. Run Below command to check existing docker images
[root@stapp02~]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE [root@stapp02 ~]# |
[root@stapp02 ~]# docker pull nginx:stable stable: Pulling
from library/nginx 69692152171a:
Pull complete 94d185f62f0a:
Pull complete da9d3d3df3e3:
Pull complete 1c11b8f3980d:
Pull complete 541b1d41bb91:
Pull complete d8f6ef04dfa8:
Pull complete Digest:
sha256:ba7669e39b8ec8b3ec9a7fba50a56dfc05c456388ee180ab263b498ee0b8724f Status:
Downloaded newer image for nginx:stable docker.io/library/nginx:stable [root@stapp02~]# |
[root@stapp02 ~]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE nginx stable 993ef3592f66 2 weeks ago 133MB [root@stapp02 ~]# |
[root@stapp02 ~]# docker container run -d --name apps -p 8084:80 nginx:stable ee8f2485f01d8565546ccfe9f56c472627c95f67abd29e288ee587c8a810281c [root@stapp02 ~]# |
7. Validate the task by below command and curl
[root@stapp02 ~]# docker ps CONTAINER
ID IMAGE COMMAND CREATED STATUS PORTS NAMES ee8f2485f01d nginx:stable "/docker-entrypoint.…" 7 seconds ago Up 4 seconds 0.0.0.0:8084->80/tcp apps [root@stapp02 ~]# curl http://localhost:8084 <!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@stapp02
~]# |
8. Click on Finish & Confirm to complete the task successful
Happy Learning!!!!
0 Comments