Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Docker - commit container with running processes (postgresql)

Tags:

docker

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?

like image 384
Dan Avatar asked Dec 28 '25 19:12

Dan


1 Answers

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.

like image 115
ISanych Avatar answered Dec 30 '25 15:12

ISanych



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!