start redis-server on debian/ubuntu boot

I am trying to create a docker container where redis starts at boot.
there will be other foreground services running on that other container which will connect to the redis db.

for some reason the service does not start when i run the container.
here my simplified Dockerfile

  • Livereload of ionic 2 with docker-compose instance does not work
  • Unable to copy source code with docker build
  • Composer install doesn't install packages when running in Dockerfile
  • AutoScaling in Docker Containers
  • Can docker services only be attached to docker overlay networks?
  • Does anyone have a working trivial example of a Dockerfile & command line that mount an external directory from linux into the docker image?
  • FROM debian
    
    # this solves an issue described here:
    # http://askubuntu.com/questions/365911/why-the-services-do-not-start-at-installation
    RUN sed -i -e s/101/0/g /usr/sbin/policy-rc.d
    
    # install redis-server
    RUN apt-get update && apt-get install -y redis-server
    
    # updates init script (redundant)
    RUN update-rc.d redis-server defaults 
    
    # ping google to keep the container running in foreground
    CMD ["ping", "google.com"]
    

    can anybody explain me why this is not working and how this should be done right?

  • Connecting to MySQL Server on localhost through Docker
  • Doing AEM Quick Install once when building a docker image
  • Detect if my app runs in Azure
  • Docker volume does not persist data
  • docker on OSX slow volumes
  • How to make docker-compose volumes work on Hyper-V?
  • One Solution collect form web for “start redis-server on debian/ubuntu boot”

    So a docker container is like a full OS but has some key differences. It’s not going to run a full init system. It’s designed and intended to run a single process tree. While you can run a supervisor such as runit et al within a container, you are really working against the grain of docker and all the tooling and documentation is going to lead you away from using containers like VMs and toward the harmony of 1 process/service per container.

    So redis isn’t starting because the ping command is literally the only process running in your container.

    there will be other foreground services running on that other container which will connect to the redis db.

    Don’t do it this way. Really. Everything will be easier when you put 1 process in each container and connect them via network links.

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.