How to start a consul client running in a docker container?

Update: I overlooked the progrium/consul page on dockerhub which had the solution to my question.

Question:

  • Starting Consul in docker does not expose http ports
  • Issue when joining serf nodes located in different Docker containers
  • Consul for Docker container discovery: how to get latest container in Consul-Template?
  • cannot ping container in another host with docker consul
  • How to use kong server with etcd or consul?
  • Consul Empty reply from server
  • So I am running consul in the progrium/consul container. I am running 3 servers joined together and would like to add some consul clients. However I have not been able to find any guides that detail how to start consul clients using the progrium/consul container. Here is my current attempt to start a client:

    Note that $CLIENT_IP_ADDR is my clients IP address and $CONSUL_SERVER0, $CONSUL_SERVER1 and $CONSUL_SERVER2 are the IP addresses of my consul servers.

    docker run -d -h client0 --name client0 -v /mnt:/data \
    -p $CLIENT_IP_ADDR:8300:8300 \
    -p $CLIENT_IP_ADDR:8301:8301 \
    -p $CLIENT_IP_ADDR:8301:8301/udp \
    -p $CLIENT_IP_ADDR:8302:8302 \
    -p $CLIENT_IP_ADDR:8302:8302/udp \
    -p $CLIENT_IP_ADDR:8400:8400 \
    -p $CLIENT_IP_ADDR:8500:8500 \
    -p 172.17.0.1:53:53/udp \
    progrium/consul -client -advertise $CLIENT_IP_ADDR \
    -join $CONSUL_SERVER0 -join $CONSUL_SERVER1 -join $CONSUL_SERVER2
    

    Here are the error messages I get when I check the logs for my container:

    myUserName@myHostName:~$ docker logs client0
    ==> WARNING: It is highly recommended to set GOMAXPROCS higher than 1
    ==> Starting Consul agent...
    ==> Error starting RPC listener: listen tcp $CLIENT_IP_ADDR:8400: bind: cannot assign requested address
    

  • What is the meaning of the IDs shown when a Docker image is pulled?
  • Docker load image is not working on Windows 10
  • Can Linux Container run on a virtual machine? [closed]
  • Setup Java development environment with Docker
  • Attach stdin of docker container via websocket
  • How to expose ports only within the docker network?
  • One Solution collect form web for “How to start a consul client running in a docker container?”

    I think the answer was just to remove the -client tag from my container:

    docker run -d -h client0 --name client0 -v /mnt:/data \
    -p $CLIENT_IP_ADDR:8300:8300 \
    -p $CLIENT_IP_ADDR:8301:8301 \
    -p $CLIENT_IP_ADDR:8301:8301/udp \
    -p $CLIENT_IP_ADDR:8302:8302 \
    -p $CLIENT_IP_ADDR:8302:8302/udp \
    -p $CLIENT_IP_ADDR:8400:8400 \
    -p $CLIENT_IP_ADDR:8500:8500 \
    -p 172.17.0.1:53:53/udp \
    progrium/consul -advertise $CLIENT_IP_ADDR \
    -join $CONSUL_SERVER0 -join $CONSUL_SERVER1 -join $CONSUL_SERVER2
    

    Apparently its the default mode of this container https://hub.docker.com/r/progrium/consul/. I think its running in client mode because my client0 node does not appear under the consul service. Only my 3 consul servers appear there.

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