在将Django项目通过Docker部署到生产环境前,需要在本地测试Docker镜像是否可用。
部署的项目用UWSGI作为服务器,生成容器后,访问admin页面报500,于是进入容器内查看Django服务是否开启:
user@starx:~/program/my_project$ docker exec -it 33d729ba5b37 bash
root@33d729ba5b37:/home/my_project# python manage.py runserver
Performing system checks...
System check identified no issues (0 silenced).
Exception in thread django-main-thread:
Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/django/db/backends/base/base.py", line 217, in ensure_connection
self.connect()
File "/usr/local/lib/python3.7/site-packages/django/db/backends/base/base.py", line 195, in connect
self.connection = self.get_new_connection(conn_params)
File "/usr/local/lib/python3.7/site-packages/django/db/backends/mysql/base.py", line 227, in get_new_connection
return Database.connect(**conn_params)
File "/usr/local/lib/python3.7/site-packages/MySQLdb/__ini