我试图在容器中安装postgresql-9.3包含图像ubuntu:14:04
第一步,我做了图像ubuntu:14 :04
$ sudo Docker pull ubuntu:14.04第二步,我用命令创建一个容器
$ sudo docker运行-t -i ubuntu:14.04 / bin / bash第三步,我安装postgresql-容器中的9.3包含ubuntu:14.04(在包含ubuntu的容器中)
我试图进入postgresql可以,然后我试图找出容器,直接使用命令
#exit我试图登录,容器postgresql我安装丢失,是否可以做和帮助解释为什么?
Docker本身,是否在内核中运行?
硬件>操作系统> Docker。
Docker概念: p>
Docker = images> Container
解决方案您不应该在bash会话中安装任何内容。 由于docker使用 UnionFS(union filesystem service),一旦你退出了bash会话,任何修改都会丢失容器被删除。
您可以尝试退出容器的 docker commit ,但这不是如何你创建一个新的图像。
你所做的是创建一个名为 Dockerfile 的文本文件,其中你遵循类似的步骤如官方postgres图片 Dockerfile (除了你想从ubuntu开始)。
它包括:
运行apt-get update \ &&& apt-get install -y postgresql-common \ && sed -ri的/#(create_main_cluster)。* $ / \1 = false /'/etc/postgresql-common/createcluster.conf \ && apt-get install -y \ postgresql- $ PG_MAJOR = $ PG_VERSION \ postgresql-contrib- $ PG_MAJOR = $ PG_VERSION \ && rm -rf / var / lib / apt / lists / *你运行 docker build -t mypostgres。:这将构建一个包含postgres的新图像。
换句话说,Dockerfile是在声明性文本文件中继续安装步骤,您可以随时从中构建图像。
I tried to install postgresql-9.3 in the container contains images "ubuntu: 14:04"
The first step, which I did make images "ubuntu: 14:04"
$ sudo Docker pull ubuntu:14.04The second step, I create a container with the command
$ sudo docker run -t -i ubuntu:14.04 /bin/bashThe third step, I install postgresql-9.3 in a container contain "ubuntu:14.04" (in a container containing ubuntu)
I tried to get in postgresql could, then I tried to get out containers, straight out with the command
# exitI tried to log back in, the container postgresql I install missing, whether it can do and helped explain why?
Docker itself, whether running in the kernel?
Hardware> OS> Docker.
Docker concept:
Docker = images> Container
解决方案You should not install anything in a bash session. Since docker uses UnionFS (union filesystem service), as soon as you exit your bash session, any modification is lost when the container is removed.
You could try a docker commit of your "Exited" container, but that is not how you build a new image.
What you do is create a text file named Dockerfile, in which you follow similar steps as the official postgres image Dockerfile (except you want to start from ubuntu).
It includes:
RUN apt-get update \ && apt-get install -y postgresql-common \ && sed -ri 's/#(create_main_cluster) .*$/\1 = false/' /etc/postgresql-common/createcluster.conf \ && apt-get install -y \ postgresql-$PG_MAJOR=$PG_VERSION \ postgresql-contrib-$PG_MAJOR=$PG_VERSION \ && rm -rf /var/lib/apt/lists/*You the run docker build -t mypostgres .: that will build a new image which will contain postgres.
In other words, the Dockerfile is there to persists the installation steps in a declarative text file, from which you can build an image at any time.
更多推荐
Docker,在包含“ubuntu:14.04”的容器中安装postgresql,在容器外面丢失
发布评论