The Nautilus Application development team recently finished development of one of the apps that they want to deploy on a containerized platform. The Nautilus Application development and DevOps teams met to discuss some of the basic pre-requisites and requirements to complete the deployment. The team wants to test the deployment on one of the app servers before going live and set up a complete containerized stack using a docker compose fie. Below are the details of the task:
1. On App Server 2 in Stratos Datacenter create a docker compose file /opt/security/docker-compose.yml (should be named exactly).
2. The compose should deploy two services (web and DB), and each service should deploy a container as per details below:
For web service:
a. Container name must be php_host.
b. Use image php with any apache tag. Check here for more details https://hub.docker.com/_/php?tab=tags.
c. Map php_host container's port 80 with host port 8089
d. Map php_host container's /var/www/html volume with host volume /var/www/html.
For DB service:
a. Container name must be mysql_host.
b. Use image mariadb with any tag (preferably latest). Check here for more details https://hub.docker.com/_/mariadb?tab=tags.
c. Map mysql_host container's port 3306 with host port 3306
d. Map mysql_host container's /var/lib/mysql volume with host volume /var/lib/mysql.
e. Set MYSQL_DATABASE=database_host and use any custom user ( except root ) with some complex password for DB connections.
3. After running docker-compose up you can access the app with curl command curl <server-ip or hostname>:8089/
For more details check here: https://hub.docker.com/_/mariadb?tab=description
Note: Once you click on FINISH button, all currently running/stopped containers will be destroyed and stack will be deployed again using your compose file.
Sample Answer:
#login to the correct app server as given in the question
ssh <user>@<app-server>
#switch to root user
sudo su
#now you need to create a docker-compose.yml file inside the given location.(check your question)
#hope you check the above sample docker-compose.yml and created with the details in your question.
#now deploy the file
docker-compose up -d
#if everything ok, you will not be getting any errors
#Testing
curl <server-ip or hostname>:<port>/
*Please comment on this post if you have any questions or facing any issues in the above steps, also provide your feedback in the comments :)
Note: **The Question copied for learning purposes.** Commands are correct but based on your question the server, user name, and other details might differ, so please do check.
check below video too for how to do the task (i have done a sample task on Ubuntu OS)
No comments:
Post a Comment