Introduction

this is part 22 from the journey it's a long journey(360 day) so go please check previous parts , and if you need to walk in the journey with me please make sure to follow because I may post more than once in 1 Day but surely I will post daily at least one 😍.

And I will cover lot of tools as we move on.


useful commands

this is a contd... for last part , I will talk about some useful commands that you may use on daily basis with docker-compose.

first let's stop all containers with

docker container stop $(docker container ls -a -q)

stoped

now let's say we need to run only PostgreSQL without Django image , we can do this by

docker-compose -f local.yml up postgres

postgres here is the name of the service. post We can see that PostgreSQL run without Django because in our local.yml it doesn't depend on Django. In other hand in local.yml we have Django depends on postgres. depends so when I try to run Django postgres will automatically start also.

docker-compose -f local.yml up django

django So in case in our development Database got stuck or whatever we can restart database only using

docker-compose -f local.yml restart postgres

and this will make it restart.


Exec

In case you need to interact with docker container you can use

docker-compose exec sh

exec

In my case in Django sometimes I need to used python shell to create Objects and feed them to Database. I can access python shell in same way

docker-compose exec python

python actually you can do what ever you want with exec like run a script inside the folder. Let's take example you have a script that load fake data to database.

This post is also available on DEV.