G
G
ghostku2015-06-28 23:08:44
Apache HTTP Server
ghostku, 2015-06-28 23:08:44

How to add service autostart inside docker container?

Good afternoon. I decided to study docker, which is fashionable now, and came up with a little problem for myself. The essence of the problem is that you need to periodically run a Bash script that will download data, convert and generate results in the form of html that you need to give out. In fact, I need a container with Apache installed, which will run my script every hour. I took the basic container with Ubuntu, launched it in interactive mode and installed Apache in it, set up the script launch via cron - everything is ok. Then he tried to create his own modified container using the Dockerfile and failed already at the Apache autorun stage.

# Version: 0.0.1
FROM ubuntu:14.04
RUN apt-get update && apt-get install -y apache2 
EXPOSE 80

After that I have a container with Apache installed but not running, of course I can go interactively into the container and run it. But ideally, everything should be launched with one command.
docker run -d -p 9999:80 my/image
I ask for tips on how to create your own container that can be run in the background so that Apache runs in it and the script runs once an hour.
Thanks

Answer the question

In order to leave comments, you need to log in

1 answer(s)
C
Ch00ee, 2015-10-23
@Ch00ee

docker run -d -p 9999:80 my/image /usr/sbin/apache2
try like this

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question