cookiecutter django 如何在 docker 容器/镜像中创建数据库

问题描述

运行 docker-compose -f local.yml up 如何在 postgres 容器中使用 .envs/.local/.postgres 中的配置创建 postgres 数据库。我查看了 Dockerfiles,但似乎无法找到诸如 createdb 之类的命令,除非在 maintenance/restore 文件中。

Cookiecutter-django: https://github.com/pydanny/cookiecutter-django

解决方法

千篇一律的设置环境变量,然后由 Docker 图像读取。请参阅官方文档中的 How to extend this image > Environment Variables 部分:https://hub.docker.com/_/postgres