Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change the service name generated by Docker stack in docker-compose

When deploying a stack of this compose file using:

docker stack deploy -c docker-compose.yml myapp

service-name:
    image: service-image
    namelike-property: my-custom-service-name // here I would like to know the property

The generated service name will be myapp_service-name

I would want it to be named and referenced by my-custom-service-name

like image 231
Igor L. Avatar asked Oct 03 '17 14:10

Igor L.


1 Answers

For communication between services you can use the serviceName as defined in the compose file (in your case your service name is service-name) if both services communicating are in the same network.

When you do docker service ls the stackname will be shown before every service. That's done because its possible to have two services with the same name which are not in a shared network. You can't change that and it wouldn't make sense to do that because that name is not important and is actually just an ID. You can however change the name of your stack to get ${StackNameILike}:${ServiceNameILike}

like image 147
herm Avatar answered Sep 20 '22 04:09

herm