Docker Community Forums

Share and learn in the Docker community.

Start a service inside docker container automaticly

I’ve been running a Docker container for a year or so now, the dockerfile doesn’t exist. Now I want the cron.d service to run automatically in this container (/etc/init.d/cron start). I already found a solution on stackoverflow:
CMD /etc/init.d/cron start

Now the container is already running and I don’t have a dockerfile in which I can use it to rebuild the container. I am confused at this point. How can I use CMD in a running container? Sure, I can stop it too, but that doesn’t help me because I don’t know how the command should be implemented without a dockerfile.

problem still exists

If you want to bust into the container and run that command just:

docker exec -it containerid terminal

Sorry, not a full-time unix person but you just need to enter a command that will give you a prompt. In windows it would be something like ‘powershell’ or ‘cmd’. Hope this helps.

Or you could just docker exec -t containerid /etc/init.d/cron start

so you could script this.