Docker Community Forums

Share and learn in the Docker community.

Systemd socket-activated docker container


(Bobk48) #1

Has anyone tried, or know if it’s even possible, to have a docker container start using systemd’s socket-based activation?
For example, if I set up an nginx container on my Ubuntu 16.04 or Mint 18 system, I would like my nginx container to not start until an incoming request comes in on the port it’s hooked to.
This is a fairly simple thing to do if you have a daemon written in C that you want to only start when the daemon is hooked to that socket/port, and that you have a systemd socket unit file and service file written for.
But I would like to do the same thing for Docker nginx containers. Have several of them not started, and then when requests come to any one of them, that container starts up. If you look at Lennart Poettering’s systemd for Administrator’s Blog #20, he sketches this out. But for technology from 2011.
Any help would be greatly appreciated. Perhaps something like this can be done with the Docker engine only, I don’t know.
Thanks!
Bob Koretsky