To kill all the running container created by docker compose
[root@ip-172-31-93-32 ~]# docker-compose kill
Killing root_webapp1_1 ... done
[root@ip-172-31-93-32 ~]# docker-compose ps
Name Command State Ports
--------------------------------------------------------
root_webapp1_1 nginx -g daemon off; Exit 137
[root@ip-172-31-93-32 ~]# docker-compose kill
Killing root_webapp1_1 ... done
[root@ip-172-31-93-32 ~]# docker-compose ps
Name Command State Ports
--------------------------------------------------------
root_webapp1_1 nginx -g daemon off; Exit 137
Now again if we want to start
[root@ip-172-31-93-32 ~]# docker-compose start
Starting webapp1 ... done
[root@ip-172-31-93-32 ~]# docker-compose ps
Name Command State Ports
--------------------------------------------------------------------
root_webapp1_1 nginx -g daemon off; Up 0.0.0.0:8000->80/tcp
[root@ip-172-31-93-32 ~]#
---------------------------------------------------------------------------------------------------------------
To know our docker container port 80 is mapped with which port outside world
[root@ip-172-31-93-32 ~]# docker-compose port webapp1 80
0.0.0.0:8000
-------------------------------------------------------------------------------------------------
To see the log coming to docker container
[root@ip-172-31-93-32 ~]# docker-compose logs -f
-------------------------------------------------------------------------------
To get the help use
[root@ip-172-31-93-32 ~]# docker-compose --help
----------------------------------------------------------------------------------------------
To run any command in the container use the exec command
[root@ip-172-31-93-32 ~]# docker-compose ps
Name Command State Ports
--------------------------------------------------------------------
root_webapp1_1 nginx -g daemon off; Up 0.0.0.0:8000->80/tcp
[root@ip-172-31-93-32 ~]# docker container ls -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
c834fe29a103 nginx "nginx -g 'daemon of…" 16 minutes ago Up 13 minutes 0.0.0.0:8000->80/tcp root_webapp1_1
[root@ip-172-31-93-32 ~]# docker-compose exec webapp1 ls --------This ran ls command inside running container webapp1
bin dev home lib64 mnt proc run srv tmp var
boot etc lib media opt root sbin sys usr
[root@ip-172-31-93-32 ~]#
-----------------------------------------------------------------------------------------------
[root@ip-172-31-93-32 ~]# docker-compose run webapp1 ls
bin dev home lib64 mnt proc run srv tmp var
boot etc lib media opt root sbin sys usr
[root@ip-172-31-93-32 ~]# docker-compose ps
Name Command State Ports
--------------------------------------------------------------------
root_webapp1_1 nginx -g daemon off; Up 0.0.0.0:8000->80/tcp
[root@ip-172-31-93-32 ~]# docker container ls -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
10d52c52b364 nginx "ls" 23 seconds ago Exited (0) 22 seconds ago root_webapp1_run_816095b9c49c
c834fe29a103 nginx "nginx -g 'daemon of…" 22 minutes ago Up 19 minutes 0.0.0.0:8000->80/tcp root_webapp1_1
[root@ip-172-31-93-32 ~]#
Note:-- So difference between run and exec is that
exec command ------> run the command in the same running container
run command--------> run the command in new container and after running the command kill the container
---------------------------------------------------------------------------------------------------------
To restart the container
[root@ip-172-31-93-32 ~]# docker-compose restart
Restarting root_webapp1_1 ... done
[root@ip-172-31-93-32 ~]#
---------------------------------------------------------------------------------------------------------------
To download the image from docker hub
[root@ip-172-31-93-32 ~]# docker-compose pull
Pulling webapp1 ... done
[root@ip-172-31-93-32 ~]#
----------------------------------------------------------------------------------------------------------
To check the docker compose version
[root@ip-172-31-93-32 ~]# docker-compose --version
docker-compose version 1.24.0, build 0aa59064
[root@ip-172-31-93-32 ~]#
No comments:
Post a Comment