-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker_commands.txt
More file actions
109 lines (75 loc) · 2.36 KB
/
Copy pathdocker_commands.txt
File metadata and controls
109 lines (75 loc) · 2.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
Docker flow for Car Rental System
=================================
Prerequisites
-------------
1. Install Docker Desktop.
2. Start Docker Desktop.
3. Run all commands from the project root:
C:\Python Pycharm\Car-Rental-System
Build and start the full project
--------------------------------
docker compose up --build
Open the application:
http://localhost:8000/
Open Django admin:
http://localhost:8000/admin/
Run in background
-----------------
docker compose up --build -d
View logs:
docker compose logs -f
View only Django logs:
docker compose logs -f web
View only Celery worker logs:
docker compose logs -f celery
View only Celery beat logs:
docker compose logs -f celery-beat
Database and Django commands
----------------------------
Run migrations manually:
docker compose exec web python manage.py migrate
Create an admin user:
docker compose exec web python manage.py createsuperuser
Collect static files:
docker compose exec web python manage.py collectstatic --noinput
Open Django shell:
docker compose exec web python manage.py shell
Run tests:
docker compose exec web python manage.py test
Service commands
----------------
Start containers:
docker compose start
Stop containers:
docker compose stop
Restart containers:
docker compose restart
Stop and remove containers, keeping database/media volumes:
docker compose down
Stop and remove containers plus database/media/cache volumes:
docker compose down -v
Rebuild after dependency or Dockerfile changes
----------------------------------------------
docker compose build --no-cache
docker compose up
Useful container access
-----------------------
Open a shell inside the Django container:
docker compose exec web sh
Open PostgreSQL shell:
docker compose exec db psql -U postgres -d car_rental_db
Open Redis CLI:
docker compose exec redis redis-cli
Project services in Docker
--------------------------
web Django application on http://localhost:8000
db PostgreSQL database on localhost:5432
redis Redis cache and Celery broker on localhost:6379
celery Celery background worker
celery-beat Celery scheduled task runner
Notes
-----
The web container automatically runs:
python manage.py migrate --noinput
python manage.py collectstatic --noinput
The Docker Compose file reads .env, but overrides DB_HOST and Redis URLs inside Docker so containers can communicate with each other.