close
Skip to content

[BUG] service "[service name]" is not running container #1 #10761

@armenak-baburyan

Description

@armenak-baburyan

Description

After scaling up the service, deleting the old container, and scaling down, an error occurs when attempting docker compose exec: service "myservice" is not running container #1. This error should not occur.

Steps To Reproduce

  1. docker-compose.yml
version: '3.8'

services:
  myservice:
    image: alpine:latest
    command: tail -F anything

Run service

~ docker compose up -d
[+] Building 0.0s (0/0)
[+] Running 2/2
 ✔ Network myservice_default        Created                                                                                                                                                                              0.1s
 ✔ Container myservice-myservice-1  Started
 
~ docker compose ps
NAME                    IMAGE               COMMAND              SERVICE             CREATED             STATUS              PORTS
myservice-myservice-1   alpine:latest       "tail -F anything"   myservice           4 seconds ago       Up 3 seconds

~ docker ps --filter name=myservice
CONTAINER ID   IMAGE           COMMAND              CREATED         STATUS         PORTS     NAMES
9b6a621370a1   alpine:latest   "tail -F anything"   2 minutes ago   Up 2 minutes             myservice-myservice-1

exec command in service - ok

~ docker compose exec myservice /bin/sh
/ # exit

Scaling up myservice

~ docker compose up -d --no-deps --scale myservice=2 --no-recreate myservice
[+] Building 0.0s (0/0)
[+] Running 2/2
 ✔ Container myservice-myservice-1  Running                                                                                                                                                                              0.0s
 ✔ Container myservice-myservice-2  Started                                                                                                                                                                              0.5s

~ docker compose ps
NAME                    IMAGE               COMMAND              SERVICE             CREATED             STATUS              PORTS
myservice-myservice-1   alpine:latest       "tail -F anything"   myservice           2 minutes ago       Up 2 minutes
myservice-myservice-2   alpine:latest       "tail -F anything"   myservice           8 seconds ago       Up 7 seconds

~ docker ps --filter name=myservice
CONTAINER ID   IMAGE           COMMAND              CREATED          STATUS          PORTS     NAMES
8e82f3dc8363   alpine:latest   "tail -F anything"   13 seconds ago   Up 13 seconds             myservice-myservice-2
9b6a621370a1   alpine:latest   "tail -F anything"   2 minutes ago    Up 2 minutes              myservice-myservice-1

~ docker compose exec myservice /bin/sh
/ # exit

Stop and remove old container and scaling down myservice

~ docker stop 9b6a621370a1
9b6a621370a1

~ docker rm 9b6a621370a1
9b6a621370a1

~ docker compose up -d --no-deps --scale myservice=1 --no-recreate myservice
[+] Building 0.0s (0/0)
[+] Running 1/0
 ✔ Container myservice-myservice-2  Running                                                                                                                                                                              0.0s

~ docker compose ps
NAME                    IMAGE               COMMAND              SERVICE             CREATED             STATUS              PORTS
myservice-myservice-2   alpine:latest       "tail -F anything"   myservice           3 minutes ago       Up 3 minutes

Trying to exec command again. This time got an error

~ docker compose exec myservice /bin/sh
service "myservice" is not running container #1

Compose Version

Docker Compose version v2.18.1

Docker Environment

Client: Docker Engine - Community
 Version:    24.0.2
 Context:    default
 Debug Mode: false
 Plugins:
  buildx: Docker Buildx (Docker Inc.)
    Version:  v0.10.5
    Path:     /usr/libexec/docker/cli-plugins/docker-buildx
  compose: Docker Compose (Docker Inc.)
    Version:  v2.18.1
    Path:     /usr/libexec/docker/cli-plugins/docker-compose
  scan: Docker Scan (Docker Inc.)
    Version:  v0.23.0
    Path:     /usr/libexec/docker/cli-plugins/docker-scan

Server:
 Containers: 63
  Running: 62
  Paused: 0
  Stopped: 1
 Images: 136
 Server Version: 24.0.2
 Storage Driver: overlay2
  Backing Filesystem: extfs
  Supports d_type: true
  Using metacopy: false
  Native Overlay Diff: true
  userxattr: false
 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.runc.v2 runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: 3dce8eb055cbb6872793272b4f20ed16117344f8
 runc version: v1.1.7-0-g860f061
 init version: de40ad0
 Security Options:
  apparmor
  seccomp
   Profile: builtin
 Kernel Version: 5.4.0-152-generic
 Operating System: Ubuntu 20.04.6 LTS
 OSType: linux
 Architecture: x86_64
 CPUs: 4
 Total Memory: 15.62GiB
 Name: dev
 ID: VDKE:NM7F:AVYW:TNS4:7CCQ:RFYD:4SKV:AO6D:FIIM:ZWXR:WOTP:E6YI
 Docker Root Dir: /mnt/dev_data/docker
 Debug Mode: false
 Experimental: false
 Insecure Registries:
  127.0.0.0/8
 Live Restore Enabled: false

WARNING: No swap limit support

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions