Docker-提交具有正在运行的进程的容器(PostgreSQL) [英] Docker - commit container with running processes (postgresql)

查看:86
本文介绍了Docker-提交具有正在运行的进程的容器(PostgreSQL)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在运行postgresql的情况下提交容器,以便立即准备就绪?我已经尝试使用启动脚本CMD和bashrc来启动postgresql,使用它们都可以很好地启动

Is it possible to commit a container with postgresql running so that it is ready immediately? I have tried using a startup script, CMD and bashrc to start postgresql, which all start it fine when using

docker run -it [containerID]

docker run -it [containerID]

但是登录后,大约需要3-5秒才能显示出来.不幸的是,我需要登录时运行postgresql.

but it takes approximately 3-5 seconds for postgresql to come up once logged in. I unfortunately need postgresql running on login.

使用这种方法...

docker build -t [名称]

docker build -t [name]

docker run -it [containerId]

docker run -it [containerId]

然后在容器内运行

服务postgresql启动

service postgresql start

并使用ctrl p + q分离.分离后,我提交

and detach with ctrl p + q. Once detached I commit with

docker commit [containerId] [名称]

docker commit [containerId] [name]

运行新映像时,postgresql未运行,并且锁文件被保留.可以提交这样的正在运行的服务,还是有办法在运行映像时准备好Postgresql?

Upon running the new image, postgresql is not running and the lock file is left over. Is it possible to commit a running service like this or is there a way to have postgresql ready upon running the image?

推荐答案

图像只是一组文件,没有进程,因此问题没有道理.当您从映像启动容器时,进程将在此处开始-进程仅存在于正在执行的容器中,当容器停止时不再存在进程-仅来自容器文件系统中的文件.

Image is just a set of files there are no processes, so question does not make sense. When you start container from image then process will start here - processes exists only in executing container, when container stops there are no processes anymore - only files from container's filesystem.

这篇关于Docker-提交具有正在运行的进程的容器(PostgreSQL)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆