Update : with docker 1.13 now have a similar flag for adding entries to /etc/host .
To add a host when creating a service, you can use the --host flag:
docker service create --name myapp --host "hbasehost:xxx.xxx.xxx.xxx" --replicas 5 myimage
To update the service and add an additional host after creating it, use the --host-add flag:
docker service update --host-add "hbase:xxxx" myapp
You can also remove the host using --host-rm .
Original answer
--add-host only adds the host:IP association to /etc/hosts .
You can switch from --add-host to environment variables with --env , although this will require minor changes in your application to use the environment variable instead of the host name to connect to hbase.
# Applies environment variables for all tasks in a service. docker service create --name myapp --replicas=5 --env HBASEHOST=xxx.xxx.xxx.xxx myimage
Then you can scale the service using:
docker service scale myapp=20
Additional tasks should be able to use an environment variable to connect to hbase.
Source : I am a third-party assistant to Docker Swarmkit
abronan
source share