我在一个docker容器中运行postgres,以限制它可以访问的系统资源的数量。我在理解如何使数据持久化方面遇到了一些问题。我已经阅读了以下文章:
它建议使用纯数据容器,然后让我的postgres容器链接到它。我不能理解的是:这样做有什么好处?据我所知,如果docker-machine由于某种原因关闭(例如,将其移动到另一台物理计算机),仅数据容器停止运行,并且它的所有内容都会丢失?我尝试在postgres容器中创建一个卷,但实际上似乎没有将任何内容保存到磁盘。
这是我的文档。我做错了什么?
FROM ubuntu
MAINTAINER Andrew Broadbent <andr
我知道我可以将postgres图像的默认文件夹更改为指向卷--在这种情况下,卷显然将保持不变。但我没有这么做,因为我想了解这个图像的默认行为。
所以我就跑了:
# in one terminal
docker pull postgres
# as a foreground process:
docker run -P --name dev_db postgres
# in another terminal
docker run --rm -it --link dev_db:dev_db /bin/bash
# in this container, I created some databas
我已经构建了一个测试应用程序来更好地理解FastAPI和sqlalchemy的概念,我希望这个应用程序能够提供一个docker-compose.yml,可以通过执行docker-compose up来运行我的解决方案。
但我得到了
Building al_test
Traceback (most recent call last):
File "docker-compose", line 3, in <module>
File "compose\cli\main.py", line 67, in main
File "compos
我运行的是Mac原生Docker (没有virtualbox/docker-machine)。
我有一个巨大的图像,里面有很多基础设施(Postgres等)。我已经运行了清理脚本来清除大量的杂物--未使用的图像等等。
当我运行我的镜像时,我得到如下错误:
could not create directory "/var/lib/postgresql/data/pg_xlog": No space left on device
在我的主机Mac上,/var有60%的可用空间,通常我的磁盘有很多可用存储空间。
这是不是我需要提升的Docker配置才能给它更多的资源?
来自mount
我试图在Docker中构建一个debian映像,其中包含nginx、postgresql和php。我已经设法让nginx和php工作了。Postgres也在工作,但我无法将模式添加到我创建的数据库中。
Dockerfile中有关postgres的代码(从docker网站获得)如下:
# Add database
RUN apt-get update && apt-get install -y postgresql-9.4 postgresql-client-9.4 postgresql-contrib-9.4
# Run the rest of the commands as
我希望使用一个docker容器来模拟我的生产环境,所以我将db和服务器安装在同一个容器中,而不是在他自己的容器中安装。
这是我的文件:
FROM debian
RUN apt update
RUN apt install postgresql-9.6 tomcat8 tomcat8-admin -y
RUN service postgresql start
RUN service postgresql status # says postgres is down
RUN su - postgres ;
RUN createdb db_example # fails !!!
RUN psql -