Docker - commit container with running processes (

2019-05-21 18:11发布

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]

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

Using this approach...

docker build -t [name]

docker run -it [containerId]

Inside of the container I then run

service postgresql start

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

docker commit [containerId] [name]

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?

标签: docker
1条回答
Melony?
2楼-- · 2019-05-21 18:21

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.

查看更多
登录 后发表回答