[英]Django Docker/Kubernetes Postgres data not appearing
I just tried switching from docker-compose to docker stacks/kubernetes. 我只是尝试从docker-compose切换到docker stacks / kubernetes。 In compose I was able to specify where the postgres data volume was and the data persisted nicely.
在撰写过程中,我能够指定postgres数据量在哪里,并且数据可以持久保存。
volumes:
- ./postgres-data:/var/lib/postgresql/data
I tried doing the same thing with the stack file and I can connect to the pod and use psql to see the schema but none of the data entered from docker-compose is there. 我尝试对堆栈文件执行相同的操作,我可以连接到pod并使用psql查看架构,但是从docker-compose输入的数据均不存在。
Any ideas why this might be? 任何想法为什么会这样?
Here's the stack.yml 这是stack.yml
version: '3.3'
services:
django:
image: image
build:
context: .
dockerfile: docker/Dockerfile
deploy:
replicas: 5
environment:
- DJANGO_SETTINGS_MODULE=config.settings.local
- SECRET_KEY=password
- NAME=postgres
- USER=postgres
- HOST=db
- PASSWORD=password
- PORT=5432
volumes:
- .:/application
command: ["gunicorn", "--bind 0.0.0.0:8000", "config.wsgi"]
ports:
- "8000:8000"
links:
- db
db:
image: mdillon/postgis:9.6-alpine
volumes:
- ./postgres-data:/var/lib/postgresql/data
You failed to mention how your cluster is provisioned, where is it running etc. so I will make an assumption we're talking about local tests here. 您没有提到群集的配置方式,群集的运行位置等。因此,我假设我们在这里谈论本地测试。 If so, you probably have local docker/docker-compose and minikube installed.
如果是这样,您可能已经安装了本地docker / docker-compose和minikube。
If that is the case, please mind that minikube runs in it's own VM so it will not be affected by changes you make on your host by ie. 如果是这种情况,请注意minikube在它自己的VM中运行,因此它不会受到您在ie上对主机所做的更改的影响。 docker, as it has it's own filesystem in vm.
docker,因为它在vm中具有自己的文件系统。
Hint: you can run docker against docker daemon of minikube if you first run eval $(minikube docker-env)
提示:如果您首先运行
eval $(minikube docker-env)
则可以针对minikube的docker守护程序运行eval $(minikube docker-env)
对于docker stacks,运行docker inspect命令,它应该显示Postgres容器的安装点。
docker service inspect --format='{{range .Spec.TaskTemplate.ContainerSpec.Mounts}} {{.Source}}{{end}}' <StackName>
在上一次Docker Edge更新中修复。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.