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:
On App Server 2 in Stratos Datacenter create a docker compose file /opt/itadmin/docker-compose.yml (should be named exactly).
The compose should deploy two services (web and DB), and each service should deploy a container as per details below:
For web service:
php_web.php with any apache tag. Check docker hub for more details.80 with host port 6400/var/www/html volume with host volume /var/www/html.For DB service:
mysql_web.mariadb with any tag (preferably latest). Check mariadb for more details.3306 with host port 3306/var/lib/mysql volume with host volume /var/lib/mysql.MYSQL_DATABASE=database_web and use any custom user ( except root ) with some complex password for DB connections.After running docker-compose up you can access the app with curl command curl <server-ip or hostname>:6400/
For more details check mariadb.
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.
In this daily challenge, we are going to dockerized a 2-tier application. We have to create a docker compose file bundled with frontend and database containers. let’s start…
Create a docker compose file
sudo touch /opt/itadmin/docker-compose.yml
Copy-paste the following contents inside /opt/itadmin/docker-compose.yml
services:
web:
image: php:apache
container_name: php_web
ports:
- 6400:80
volumes:
- /var/www/html:/var/www/html
db:
image: mariadb:latest
container_name: mysql_web
ports:
- 3306:3306
volumes:
- /var/lib/mysql:/var/lib/mysql
environment:
- MARIADB_DATABASE=database_web
- MARIADB_USER=kkloud
- MARIADB_PASSWORD=your-user-password
- MARIADB_ROOT_PASSWORD=your-root-password
Let’s Test
docker compose -f /opt/itadmin/docker-compose.yml
It was actually a sample test, web server is not rely on db. Otherwise we had to set connection between two services.