Docker Community Forums

Share and learn in the Docker community.

Autostart services when container is start

(Olexander Kutsenko) #1

How can i add services to autostart?
Using ubuntu imagine.
Need to autostart mysql service for example.
I had add it to rc.local but after container restarts - i have not started mysql service.

(Sven Dowideit) #2

you may want to review some of the examples in the documentation, as much of the time, you don’t auto-start services in a container, you run one service in the foreground.

The only time you need an init service in a container, is if you need to run more than one service at the same time - in which case there are some articles that cover several options.

(Olexander Kutsenko) #3

What i should add in my run oprions:

sudo docker run -i -t -d -p 8888:8888 myimage /bin/bash

to start script in file