Starting services within container on restart ! No Docker Compose method

Dears,

I have an issue. I have a bunch of services that run within the docker container.

For example, mysql / apache

I want to start these services inside the container when it restarts/reboots. This is not with docker-compose as I don’t have a docker file.

I want to start these services at run level, just like you would do on a Centos ==> chkconfig mysqld on

Please help !

Thanks,

I figure you didn’t read the docker run documentation, did you?
Otherwise you would have seen the –restart option

If you realy want to start a container as a service, you might want to write a systemd service for it:

Are the oldschool init.d scripts still supported these days?

Sorry, but I guess you haven’t understood the question.

This is not about the docker itself. I am referring to the services running inside the docker. When I stop the container and start it again, I have to manually start the services within the container (mysql and apache) by logging into the docker.

Oh, i see. I never would have imagined that the discussion is about finding a workaround for an image that is not designed according the docker way of “one service per container”. I am not going to tell you how to ride a dead horse :wink:

Though, I would strongy advice to replace your self made image with a set of official docker images from Dockerhub and learn how to wire them together with docker-compose.

Well, this is a packaged application and we have developed it. There is no hard and fast rule in terms of design.

We often ship the image here and there for demo purposes to the client.

The issue is we can’t start the services inside the docker. Every time the docker starts, the services need to be manually started from inside.

If you realy want to use docker I would strongly suggest to adopt the underliying patterns. Ignoring them and trying to apply patterns from the vm world brought you to this point.

If you are not willing to adopt, you will be better off in shipping a vm. If you don’t want to loose the infructure as code approach -> you can use HashiCorp Packer to script the creation of VMs.

The minimum VM size is 5GB and with docker we are doing 332 MB only for our application. Docker is definitely more portable! We’ll stick to it

I appreciate that you have been answering, but you have proposed more on changing the design altogether which is not needed.

We had just asked to for the services within the docker container to be automatically started on start/restart, pretty much like on system boot (init scripts) or something similar. Strange to see that there has been no solution on it !

Best Regards,