1

I would like to run a daemon on the host and get the containers connect to it. I was thinking I will bind the daemon on the host to 127.0.0.1 and then have something (delegate? or is iptables enough?) forward packets from the IP of docker0 to the daemon. So the questions are

  1. How do I start something when the docker daemon starts
  2. What is that something?

I am on Debian 7.

The following questions seem relevant but AFAIK aren't answers:

  1. connecting from docker container to docker host
  2. https://stackoverflow.com/questions/25413954/how-to-setup-docker-to-talk-to-non-dockerized-service-on-same-host
  3. https://stackoverflow.com/questions/24319662/from-inside-of-a-docker-container-how-do-i-connect-to-the-localhost-of-the-mach
  • For the addressing part (127.0.0.1 will be the local IP of the container, will not connect to the host), see stackoverflow.com/a/27564532/448734 – Bryan Dec 19 '14 at 15:56
  • 1. The docker daemon is started by init; you can start your process the same way. and 2. it's you that wants the daemon; you need to know what it is. Could you try rephrasing the question? – Bryan Dec 19 '14 at 15:59
0

What I've found instead is -- most daemons are capable of using Unix sockets and you can mount that socket from the host into the container with -v . The ancient trick of everything is a file comes very handy. For eg docker run -v /var/run/mysqld/mysqld.sock:/tmp/mysql.sock. Inside the container you will connect to /tmp/mysql.sock. Also the same trick works with mounting the directory containing the socket -- this can be used to run X Windows applications within docker without SSH forward: just do -v /tmp/.X11-unix:/tmp/.X11-unix.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.