Skip to content
This repository has been archived by the owner on Nov 27, 2023. It is now read-only.

docker compose stop <service> stops services that the mentioned service depends on #1650

Closed
fizker opened this issue May 6, 2021 · 1 comment

Comments

@fizker
Copy link

fizker commented May 6, 2021

Description

When stopping a specific service, all services that the specified service depends on also stops. This is different from how docker-compose stop <service> functions.

Steps to reproduce the issue:

  1. Create the three files pasted below in an empty folder
  2. docker compose up -d to start all services
  3. docker compose stop sub to stop the desired service

Describe the results you received:

Both sub and base was stopped.

Describe the results you expected:

Only sub was stopped. This is what docker-compose stop sub does.

Local output after starting and stopping services

$ docker compose up -d
[+] Running 3/3
⠿ Container stop-stops-all_base_1   Started
⠿ Container stop-stops-all_extra_1  Started
⠿ Container stop-stops-all_sub_1    Started

$ docker compose ps
NAME                     SERVICE             STATUS              PORTS
stop-stops-all_base_1    base                running
stop-stops-all_extra_1   extra               running
stop-stops-all_sub_1     sub                 running

$ docker compose stop sub
[+] Running 2/2
 ⠿ Container stop-stops-all_sub_1   Stopped
 ⠿ Container stop-stops-all_base_1  Stopped

$ docker compose ps   
NAME                     SERVICE             STATUS              PORTS
stop-stops-all_extra_1   extra               running

$ docker compose up -d
[+] Running 3/3
⠿ Container stop-stops-all_extra_1  Running
⠿ Container stop-stops-all_base_1   Started
⠿ Container stop-stops-all_sub_1    Started

$ docker-compose stop sub
Stopping stop-stops-all_sub_1 ... done

$ docker compose ps
NAME                     SERVICE             STATUS              PORTS
stop-stops-all_base_1    base                running
stop-stops-all_extra_1   extra               running

Output of docker version:

Client: Docker Engine - Community
 Cloud integration: 1.0.12
 Version:           20.10.5
 API version:       1.41
 Go version:        go1.13.15
 Git commit:        55c4c88
 Built:             Tue Mar  2 20:13:00 2021
 OS/Arch:           darwin/amd64
 Context:           default
 Experimental:      true

Server: Docker Engine - Community
 Engine:
  Version:          20.10.5
  API version:      1.41 (minimum version 1.12)
  Go version:       go1.13.15
  Git commit:       363e9a8
  Built:            Tue Mar  2 20:15:47 2021
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.4.4
  GitCommit:        05f951a3781f4f2c1911b05e61c160e9c30eaa8e
 runc:
  Version:          1.0.0-rc93
  GitCommit:        12644e614e25b05da6fd08a38ffa0cfe1903fdec
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

Output of docker context show:

default

Output of docker info:

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: 66
  Running: 4
  Paused: 0
  Stopped: 62
 Images: 435
 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.runc.v2 io.containerd.runtime.v1.linux runc
 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: 4
 Total Memory: 7.776GiB
 Name: docker-desktop
 ID: OFIG:J4SK:FGX6:2VJZ:RY2V:IVOR:MK3Q:YPTM:4I65:NW5V:ZNHQ:JRG6
 Docker Root Dir: /var/lib/docker
 Debug Mode: true
  File Descriptors: 75
  Goroutines: 71
  System Time: 2021-05-06T09:22:42.4466015Z
  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

Files used in test

docker-compose.yml

version: "3.8"
services:
  base:
    build: .
  sub:
    build: .
    depends_on:
      - base
  extra:
    build: .

Dockerfile

FROM node:alpine
WORKDIR /app

COPY . .

ENTRYPOINT [ "node", "server.js" ]

server.js

// graciously stolen from https://nodejs.org/en/about/

const http = require('http');

const hostname = '127.0.0.1';
const port = 3000;

const server = http.createServer((req, res) => {
  res.statusCode = 200;
  res.setHeader('Content-Type', 'text/plain');
  res.end('Hello World');
});

server.listen(port, hostname, () => {
  console.log(`Server running at http://${hostname}:${port}/`);
});
@ndeloof
Copy link
Collaborator

ndeloof commented May 6, 2021

Hi.
This has already been fixed by #1577
Fix is available with release 1.0.14

@ndeloof ndeloof closed this as completed May 6, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants