To use scale command and create docker container as per our requirement
[root@ip-172-31-93-32 ~]# vi docker-compose.yml
[root@ip-172-31-93-32 ~]# cat docker-compose.yml
version: '3'
services:
webapp1:
image: nginx
webapp2:
image: nginx
[root@ip-172-31-93-32 ~]# docker-compose up -d
Recreating root_webapp1_1 ... done
Creating root_webapp2_1 ... done
[root@ip-172-31-93-32 ~]# docker-compose ps
Name Command State Ports
------------------------------------------------------
root_webapp1_1 nginx -g daemon off; Up 80/tcp
root_webapp2_1 nginx -g daemon off; Up 80/tcp
[root@ip-172-31-93-32 ~]# docker-compose scale webapp1=4 webapp2=2
WARNING: The scale command is deprecated. Use the up command with the --scale flag instead.
Starting root_webapp1_1 ... done
Creating root_webapp1_2 ... done
Creating root_webapp1_3 ... done
Creating root_webapp1_4 ... done
Starting root_webapp2_1 ... done
Creating root_webapp2_2 ... done
Total 6(4+2) container are created
[root@ip-172-31-93-32 ~]# docker-compose ps
Name Command State Ports
------------------------------------------------------
root_webapp1_1 nginx -g daemon off; Up 80/tcp
root_webapp1_2 nginx -g daemon off; Up 80/tcp
root_webapp1_3 nginx -g daemon off; Up 80/tcp
root_webapp1_4 nginx -g daemon off; Up 80/tcp
root_webapp2_1 nginx -g daemon off; Up 80/tcp
root_webapp2_2 nginx -g daemon off; Up 80/tcp
Now to delete all
[root@ip-172-31-93-32 ~]# docker-compose down
Stopping root_webapp2_2 ... done
Stopping root_webapp1_2 ... done
Stopping root_webapp1_3 ... done
Stopping root_webapp1_4 ... done
Stopping root_webapp1_1 ... done
Stopping root_webapp2_1 ... done
Removing root_webapp2_2 ... done
Removing root_webapp1_2 ... done
Removing root_webapp1_3 ... done
Removing root_webapp1_4 ... done
Removing root_webapp1_1 ... done
Removing root_webapp2_1 ... done
Removing root_webapp1_run_816095b9c49c ... done
Removing network root_default
[root@ip-172-31-93-32 ~]#
------------------------------------------------------------------------------
Top command:- It will give the all the running process
[root@ip-172-31-93-32 ~]# docker-compose up -d
Creating network "root_default" with the default driver
Creating root_webapp1_1 ... done
Creating root_webapp2_1 ... done
[root@ip-172-31-93-32 ~]# docker-compose top
root_webapp1_1
UID PID PPID C STIME TTY TIME CMD
--------------------------------------------------------------------------------------------
root 332 32749 0 08:57 ? 00:00:00 nginx: master process nginx -g daemon off;
101 471 332 0 08:57 ? 00:00:00 nginx: worker process
root_webapp2_1
UID PID PPID C STIME TTY TIME CMD
-------------------------------------------------------------------------------------------
root 380 358 0 08:57 ? 00:00:00 nginx: master process nginx -g daemon off;
101 508 380 0 08:57 ? 00:00:00 nginx: worker process
[root@ip-172-31-93-32 ~]#
No comments:
Post a Comment