I deleted my previous post and reverted the question to the previous version as well. I misunderstood the situation based on posts in the past although asking about the RAM was not really related to whether the container name can be set when using replicas.
So now to add something actually useful to the conversation eventually, I can say that setting the reason of not supporting the container name when also using replicas is that you would have multiple containers with the same name. And you already know that is not possible. Docker will generate names only whene there is no name specified and it wonāt even add suffixes to replicas, although that would make sense, but that parameter should probably be called container_name_prefix or something like that.
Docker Swarm is used to orchestrate containers across multiple nodes, connected to a Swarm.
You need to tell it how to deploy the containers. How many you want, how to distribute them, if they should be constraint to certain nodes, or if every node should get a single instance (mode: global).
Usually you would not expose a port on a swarm service, as multiple containers might be deployed on the same node, so you would see that error.
Having multiple replicas/instances per se is not really providing any HA. Only internally if you use Docker DNS to access a target service.
Best practice is to deploy a reverse proxy on required nodes that manages internal forwarding to target services, that can be scaled higher than the number of nodes.
docker service create --name My-Nginx --replicas 3 -p 80:80 nginx
will work, it will use name as prefix (the behavior is a bit different to compose) and create a ārouting meshā (doc) on port 80 and forwards requests to nginx instances.