What does the -1 mean at the end of the docker-compose generated name

Viewed 30

Using docker-compose version: "3.7"

When not using a container_name attribute, with docker ps I can see under NAME column that the instance was renamed with the following scheme:

<project>-<service>-1

What does the -1 stand for?

1 Answers

This is a replica number. If the service has several replicas, the number will be incremented for each replica, for example docker-compose

version: "3.7"
services:
  python-cont:
    build: .
    deploy:
      replicas: 3
docker compose up -d
[+] Running 4/4
 ⠿ Network params-test_default          Created                                                                                                                                                                        0.0s
 ⠿ Container params-test-python-cont-3  Started                                                                                                                                                                        0.9s
 ⠿ Container params-test-python-cont-2  Started                                                                                                                                                                        0.8s
 ⠿ Container params-test-python-cont-1  Started
Related