Skip to content

[BUG] --scale numbering does not start at _2 even when original container name has _1 #10569

@princefishthrower

Description

@princefishthrower

Description

As the title states, if I have a container already running (let's say app_1), when I do the following:

docker-compose up -d --scale app=2 --no-recreate

I'll get the new container with name app_2 as expected.

But if I remove the old container (app_1) and rename app_2 to app_1, when I try to scale to 2 again, docker will create the new container app_3!

Of course, I would expect that it behaves as the first time I ran it, creating a new container named app_2. Is there some sort of internal instance count docker keeps around, and if so, how can I prevent or reset this counter? Or, perhaps this truly is a bug.

Steps To Reproduce

Example repository here: https://github.com/princefishthrower/docker-numbering-issue

README describes the steps / commands needed to reproduce:

There is an issue with docker's scale command. See as follows:

First, start up an instance of app:

docker-compose build --no-cache && docker-compose up -d

We get one named container docker-numbering-issue_app_1

Then, scale it up to 2 instances:

docker-compose up -d --scale app=2 --no-recreate

all is well, we get another named container docker-numbering-issue_app_2

But, if we remove docker-numbering-issue_app_1 and then rename docker-numbering-issue_app_2 to docker-numbering-issue_app_1:

docker-compose rm -f app_1 && docker rename docker-numbering-issue_app_2 docker-numbering-issue_app_1

and we try to scale again:

docker-compose up -d --scale app=2 --no-recreate

we'll see the new container is named docker-numbering-issue_app_3!!! Unexpected name generation, IMO. This could be expected behavior but I missed or couldn't find in the docs where this is explained.

Compose Version

docker-compose version 1.29.0, build 07737305
docker-py version: 5.0.0
CPython version: 3.9.0
OpenSSL version: OpenSSL 1.1.1h  22 Sep 2020

Docker Environment

Client:
 Context:    default
 Debug Mode: false
 Plugins:
  app: Docker App (Docker Inc., v0.9.1-beta3)
  buildx: Build with BuildKit (Docker Inc., v0.5.1-docker)
  scan: Docker Scan (Docker Inc., v0.6.0)

Server:
 Containers: 3
  Running: 3
  Paused: 0
  Stopped: 0
 Images: 23
 Server Version: 20.10.5
 Storage Driver: overlay2
  Backing Filesystem: extfs
  Supports d_type: true
  Native Overlay Diff: true
 Logging Driver: json-file
 Cgroup Driver: cgroupfs
 Cgroup Version: 1
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
 Swarm: inactive
 Runtimes: io.containerd.runtime.v1.linux runc io.containerd.runc.v2
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: 05f951a3781f4f2c1911b05e61c160e9c30eaa8e
 runc version: 12644e614e25b05da6fd08a38ffa0cfe1903fdec
 init version: de40ad0
 Security Options:
  seccomp
   Profile: default
 Kernel Version: 5.10.25-linuxkit
 Operating System: Docker Desktop
 OSType: linux
 Architecture: x86_64
 CPUs: 2
 Total Memory: 3.844GiB
 Name: docker-desktop
 ID: RQJB:EDSB:XJA2:536S:GBRY:CGHR:4OJY:PYL5:RBIU:77A3:23T4:G4US
 Docker Root Dir: /var/lib/docker
 Debug Mode: true
  File Descriptors: 67
  Goroutines: 65
  System Time: 2023-05-15T11:42:02.251554076Z
  EventsListeners: 3
 HTTP Proxy: http.docker.internal:3128
 HTTPS Proxy: http.docker.internal:3128
 Registry: https://index.docker.io/v1/
 Labels:
 Experimental: false
 Insecure Registries:
  127.0.0.0/8
 Live Restore Enabled: false

Anything else?

Also opened a Stackoverflow thread with the same question / problem: https://stackoverflow.com/questions/76252406/docker-compose-scale-number-naming-convention-unexpected-after-multiple-calls

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions