Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to keep docker container up?

Tags:

docker

mariadb

I created a docker container where I install mariadb-server and some more stuff (see screen), but now I want to keep the container running of course, so people can connect to the database server in the container.

The problem is that the container keeps exiting after completed running. In the last row of the screen you see i tried adding a tail -f, but that also didn't help.

These are the commands I use for building and running:

sudo docker build -t databaseserver .
sudo docker run -it -p 3306:3306 databaseserver

Please help me to just keep it running so i can connect to the running container

Screen of Dockerfile

screen of start-up.sh

like image 938
Svenmarim Avatar asked Oct 16 '25 10:10

Svenmarim


1 Answers

You should move much of startup.sh into the Dockerfile.

Then instead of calling service mysql start which starts it in 'daemon mode', you should figure out how to start it interactively.

Then you would not have to tail the logs to keep the container from closing.

At that point you could invoke docker in daemon mode or interactively (your choice) and it should just work right.

like image 107
emory Avatar answered Oct 19 '25 10:10

emory



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!