# Docker deploy with named services

**URL:** <https://forums.docker.com/t/docker-deploy-with-named-services/25121>\
**Category:** General\
**Tags:** docker\
**Created:** [November 22, 2016, 8:58am UTC](https://forums.docker.com/t/docker-deploy-with-named-services/25121 "2016-11-22T08:58:22Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![yashgt](https://avatars.discourse-cdn.com/v4/letter/y/bcef8e/32.png) [@yashgt](https://forums.docker.com/u/yashgt)\
**Post date:** [November 22, 2016, 8:58am UTC](https://forums.docker.com/t/docker-deploy-with-named-services/25121/1 "2016-11-22T08:58:22Z")

</div>

Hi,

I have defined a client and a server as docker services and am trying to deploy them such that the client can connect to the server using the server’s name.  
The stack is named e1. I notice that the containers get names with a prefix as e1. Due to this, the client cannot identify the server as my\_server, but has to connect using the name e1\_my\_server. The client code is fixed and it assume that the server is named my\_server.

How do I ensure that the client can reach the server using the service name as defined in the compose file? My real intention is to spawn multiple such stacks which are independent of each other but with services communicating with each other using names.

I use Docker version 1.13.0-rc1, build 75fd88b  
This is in swarm mode.

[admin@gol05854 compose]$ cat docker-compose.yml  
version: '3’  
services:  
my\_client\_1:  
image: yashgt/client  
build: …/client  
#restart: on-failure:3  
volumes:  
- serverlog:/log  
depends\_on:  
- my\_server  
labels:  
- "constraint:node==gol05854"  
networks:  
- mynet  
my\_server:  
image: yashgt/proc1  
#image: gophernet/netcat  
#command: -v -l -p 5000  
expose:  
- "5000"  
build: …/proc1  
#restart: on-failure:3  
volumes:  
- serverlog:/log  
labels:  
- "constraint:node==gol05854"  
networks:  
- mynet  
volumes:  
serverlog:  
driver: local  
networks:  
mynet:  
driver: overlay

[admin@gol05854 compose]$ ~/docker/docker deploy --compose-file docker-compose.yml e1  
Ignoring unsupported options: build

Ignoring deprecated options:

expose: Exposing ports is unnecessary - services on the same network can access each other’s containers on any port.

Updating service e1\_my\_server (id: ga6qk8h46xhj7553asqx49a2r)  
Updating service e1\_my\_client\_1 (id: aef0z25w8t601o4c42beziiqj)

[admin@gol05854 compose]$ docker ps  
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES  
a05dadf60bfd yashgt/proc1:latest “/bin/sh -c ./serv…” 39 minutes ago Up 38 minutes e1\_my\_server.1.9vo53zptr4b3bnsci3u86foq2  
cb7a50745cce yashgt/client:latest “/bin/sh -c ./clie…” 39 minutes ago Up 38 minutes e1\_my\_client\_1.1.hzi0fz8br8wtffhn8ctxrls17
