3

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?

1 Answer 1

8

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.

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you for the help, this makes sense. I was hoping there was a way to save the state of the file system as well as processes running within an image. But your answer is confirming what I am seeing.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.