Consul agent Docker best practice (and consul exec)

Hi. Newbie here.

I have just begun my journey with consul. I want to run consul in containers on my Docker hosts. Is this good practice? Or should I install “bare metal” alongside Docker? If running as containers, will “consul exec” work? I mean, can I execute commands on the Docker host, and not just inside the consul container?

Hi Peter,

Thanks for using Consul. Have you found this tutorial yet? I think it will answer most if not all of your questions.

That tutorial is helpful to get started, but is is a best practice guide?

Here is a more concrete question: If you have a host running 3 different services/containers, should each container have its own sidecar consul container just for itself or should there be 1 consul agent running for the host itself?

I know there are perf implications when nodes join/leave the cluster, but what other implications are there for having consul agents be sidecar process per-service?

Thanks. I have looked at it, but I cannot see where it is stated whether it is recommended to run it besides the docker runtime, or inside the docker runtime (or even if it doesn’t matter). I have also looked at the official Docker Hub image, but all I can get from that is that it is perfectly fine to run Consul in a container as long as you use the host net.

About the ‘exec’ stuff, I have only messed seriously with Docker in a couple of months, so I am also a newcomer there. When I read about the consul exec command, I was rather excited, but immediately worried that the container isolation would mean that in practice it wouldn’t be possible. Unless the way consul issues commands relies on some Docker/Linux/socket thingy I don’t know about (which is approx. 100% likely)

I will eventually get around to just try it out, but if anybody knew…