Random rpc error: code = InvalidArgument while deploying into the swarm

I’m trying to deploy a 10-container solution into docker swarm. It works just fine on my prod and test servers, although I have problems with one of my remote clients.

The OS is Ubuntu 16.4

docker -v
Docker version 18.03.1-ce, build 9ee9f40

Specifically when I’m running the command:

docker stack deploy --compose-file=docker-compose.yaml smdr

I’m getting a very weird error message.

_smdrnetworkwork smdr
failed to create network smdrnetwork: Error response from daemon: rpc error: code = InvalidArgument desc = name must be valid as a DNS name component

I can’t find this one in google no matter how I’m trying. The name of the network is smdrnetwork and it is a valid DNS name. But as you can see on the first line the name comes out as a garble and I thing something is not being parsed just right.

I already downgraded my docker from 18.6 to 18.03, but it works just fine on my local prod server on both of those versions of docker. Ubuntu 16.4 as a server here. And this is my yaml

version: '3'

services:

  #Postgres database
  nec-postgres:
    image: nec-postgres
    ports:
      - "5432:5432"
    networks:
      - smdrnetwork
    volumes: 
      - "pgdata:/var/lib/postgresql/data"
    deploy:
      mode: global
    environment:
      POSTGRES_PASSWORD: yank

  #Automatic backup for postgres
  postgres-backup:
    image: nec-postgres-backup
    networks:
      - smdrnetwork
    deploy:
      mode: global
    environment:
      - PGUSER=postgres
      - PGPASSWORD=yank
      - PREFIX=nec-backup
      - DELETE_OLDER_THAN=14400 #Delete the backups older than 10 days
      - PGDB=postgres 
      - PGHOST=nec-postgres 
    volumes:
      - "./backup:/dump"

  nec-pull:
    image: nec-pull
    networks:
      - smdrnetwork
    deploy:
      mode: global
    env_file: 
      - variables.txt
    ports:
      - "3006:3005"
    environment:
      SMDR_URL: http://nec-smdr/ 
      PULL_DELAY: 5000
      PG_HOST: nec-postgres
      PG_PASSWORD: yank

  nec-api:
    image: nec-api
    ports:
      - "3005:3005"
    networks:
      - smdrnetwork
    deploy:
      mode: global
    environment:
      APP_PORT: 3005
      PG_HOST: nec-postgres
      PG_PASSWORD: yank

  nec-smdr:
    image: nec-smdr
    ports:
      - "3007:80"    
    networks:
      - smdrnetwork
    deploy:
      mode: global

  nec-admin:
    image: nec-admin
    ports:
      - "80:80"
    networks:
      - smdrnetwork      
    deploy:
      mode: global

  portainer:
    image: portainer/portainer
    command: -H unix:///var/run/docker.sock
    networks:
      - smdrnetwork
    ports:
      - "9000:9000"
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - portainer_data:/data
    deploy:
      mode: global

  elasticsearch:
    image: docker.elastic.co/elasticsearch/elasticsearch:6.3.1
    networks: 
      - smdrnetwork
    ports:
      - "9200:9200"
      - "9300:9300"
    volumes:
      - elastic_data:/usr/share/elasticsearch/data
    deploy:
      mode: global

  kibana:
    image: docker.elastic.co/kibana/kibana:6.3.1
    networks: 
      - smdrnetwork
    ports:
      - "5601:5601"
    environment:
      ELASTICSEARCH_URL: http://elasticsearch:9200
    deploy:
      mode: global

  logstash:
    image: nec-logstash
    networks: 
      - smdrnetwork
    deploy:
      mode: global
    env_file: 
      - variables.txt
    environment:
      LS_SCHEDULE: "*/1 * * * *"
    volumes:
      - ./lastrun:/tmp/lastrun

networks:
  smdrnetwork:

volumes:
  pgdata:
  portainer_data:
  elastic_data:
  logstash_data:

Any suggestions?

The name of the service cannot have special characters in it. Change it to necpostgres should work