moby / moby

The Moby Project - a collaborative project for the container ecosystem to assemble container-based systems
https://mobyproject.org/
Apache License 2.0
68.52k stars 18.63k forks source link

docker stack deploy with --resolve-image changed does not properly publish ports #40968

Open kirinnee opened 4 years ago

kirinnee commented 4 years ago

Description docker stack deploy <app> with the flag --resolve-image changed does not update port-mapping in the ports section of the YAML file if the image does not change. However, docker service ls reflects the new port-mapping incorrectly

Steps to reproduce the issue:

  1. Use a simple application that publish HTTP server on port 8000 : stack.yml

    version: '3.8'
    
    services:
      webapp:
        image: kirinnee/rocketrs:bug-sample
        ports:
          - 8000:8000
        deploy:
          replicas: 3
  2. Run the command: docker stack deploy --prune --with-registry-auth --compose-file stack.yml --resolve-image changed app to deploy the stack

  3. Run docker service ls to check the stack deployed

    ID                  NAME                MODE                REPLICAS            IMAGE                          PORTS
    udjf30hi98u4        app_webapp          replicated          3/3                 kirinnee/rocketrs:bug-sample   *:8000->8000/tcp

    as we can see, the app is deployed on port 8000 and mapped to host's port 8000.

    We can check is by running curl http://localhost:8000

  4. Now we re-deploy by changing the port mapping: stack.yml

    version: '3.8'
    
    services:
      webapp:
        image: kirinnee/rocketrs:bug-sample
        ports:
          - 7000:8000
        deploy:
          replicas: 3
  5. Run docker service ls to check the stack deployed

    ID                  NAME                MODE                REPLICAS            IMAGE                          PORTS
    udjf30hi98u4        app_webapp          replicated          3/3                 kirinnee/rocketrs:bug-sample   *:7000->8000/tcp

    as we can see, the app is deployed on port 8000 and mapped to host's port 7000.

  6. We can wait a minute or so, but when we run curl http://localhost:7000 , there will be response

Describe the results you received: When curling http://localhost:7000:

curl : The underlying connection was closed: The connection was closed unexpectedly.

was recieved

When curling http://localhost:8000:

Hello world2!

was recieved

Describe the results you expected:

When curling http://localhost:7000:

Hello world2!

was expected

When curling http://localhost:8000:

curl : The underlying connection was closed: The connection was closed unexpectedly.

was expected

Additional information you deem important (e.g. issue happens only occasionally):

Output of docker version:

Client: Docker Engine - Community
 Version:           19.03.8
 API version:       1.40
 Go version:        go1.12.17
 Git commit:        afacb8b
 Built:             Wed Mar 11 01:23:10 2020
 OS/Arch:           windows/amd64
 Experimental:      false

Server: Docker Engine - Community
 Engine:
  Version:          19.03.8
  API version:      1.40 (minimum version 1.12)
  Go version:       go1.12.17
  Git commit:       afacb8b
  Built:            Wed Mar 11 01:29:16 2020
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          v1.2.13
  GitCommit:        7ad184331fa3e55e52b890ea95e65ba581ae3429
 runc:
  Version:          1.0.0-rc10
  GitCommit:        dc9208a3303feef5b3839f4323d9beb36df0a9dd
 docker-init:
  Version:          0.18.0
  GitCommit:        fec3683

Output of docker info:

Client:
 Debug Mode: false

Server:
 Containers: 3
  Running: 3
  Paused: 0
  Stopped: 0
 Images: 173
 Server Version: 19.03.8
 Storage Driver: overlay2
  Backing Filesystem: <unknown>
  Supports d_type: true
  Native Overlay Diff: true
 Logging Driver: json-file
 Cgroup Driver: cgroupfs
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
 Swarm: active
  NodeID: xvtuptejpoqdedibqa5min4nw
  Is Manager: true
  ClusterID: uw9ngxaasajnk07qivqlbep9o
  Managers: 1
  Nodes: 1
  Default Address Pool: 10.0.0.0/8
  SubnetSize: 24
  Data Path Port: 4789
  Orchestration:
   Task History Retention Limit: 5
  Raft:
   Snapshot Interval: 10000
   Number of Old Snapshots to Retain: 0
   Heartbeat Tick: 1
   Election Tick: 10
  Dispatcher:
   Heartbeat Period: 5 seconds
  CA Configuration:
   Expiry Duration: 3 months
   Force Rotate: 0
  Autolock Managers: false
  Root Rotation In Progress: false
  Node Address: 192.168.65.3
  Manager Addresses:
   192.168.65.3:2377
 Runtimes: runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: 7ad184331fa3e55e52b890ea95e65ba581ae3429
 runc version: dc9208a3303feef5b3839f4323d9beb36df0a9dd
 init version: fec3683
 Security Options:
  seccomp
   Profile: default
 Kernel Version: 4.19.76-linuxkit
 Operating System: Docker Desktop
 OSType: linux
 Architecture: x86_64
 CPUs: 6
 Total Memory: 21.53GiB
 Name: docker-desktop
 ID: CTCK:FLJV:TYX7:MV5E:AYYG:TGPK:HPHN:ZZKW:TWFV:LWIT:RTGZ:TWM2
 Docker Root Dir: /var/lib/docker
 Debug Mode: true
  File Descriptors: 84
  Goroutines: 212
  System Time: 2020-05-14T05:01:36.926139175Z
  EventsListeners: 6
 Registry: https://index.docker.io/v1/
 Labels:
 Experimental: false
 Insecure Registries:
  127.0.0.0/8
 Live Restore Enabled: false
 Product License: Community Engine

Additional environment details (AWS, VirtualBox, physical, etc.): Windows 10, physical.

Archeri2000 commented 4 years ago

Bug replicated on Ubuntu 18.04 over AWS. Output of docker version

 Version:           19.03.8
 API version:       1.40
 Go version:        go1.12.17
 Git commit:        afacb8b7f0
 Built:             Wed Mar 11 01:25:46 2020
 OS/Arch:           linux/amd64
 Experimental:      false

Server: Docker Engine - Community
 Engine:
  Version:          19.03.8
  API version:      1.40 (minimum version 1.12)
  Go version:       go1.12.17
  Git commit:       afacb8b7f0
  Built:            Wed Mar 11 01:24:19 2020
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.2.13
  GitCommit:        7ad184331fa3e55e52b890ea95e65ba581ae3429
 runc:
  Version:          1.0.0-rc10
  GitCommit:        dc9208a3303feef5b3839f4323d9beb36df0a9dd
 docker-init:
  Version:          0.18.0
  GitCommit:        fec3683

Output of docker info

Client:
 Debug Mode: false

Server:
 Containers: 3
  Running: 3
  Paused: 0
  Stopped: 0
 Images: 1
 Server Version: 19.03.8
 Storage Driver: overlay2
  Backing Filesystem: <unknown>
  Supports d_type: true
  Native Overlay Diff: true
 Logging Driver: json-file
 Cgroup Driver: cgroupfs
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
 Swarm: active
  NodeID: fbu6eociz4v21stwhg0yffpuk
  Is Manager: true
  ClusterID: xzg06pe2ne4yw6ooaetvx42rl
  Managers: 1
  Nodes: 1
  Default Address Pool: 10.0.0.0/8
  SubnetSize: 24
  Data Path Port: 4789
  Orchestration:
   Task History Retention Limit: 5
  Raft:
   Snapshot Interval: 10000
   Number of Old Snapshots to Retain: 0
   Heartbeat Tick: 1
   Election Tick: 10
  Dispatcher:
   Heartbeat Period: 5 seconds
  CA Configuration:
   Expiry Duration: 3 months
   Force Rotate: 0
  Autolock Managers: false
  Root Rotation In Progress: false
  Node Address: 172.31.25.47
  Manager Addresses:
   172.31.25.47:2377
 Runtimes: runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: 7ad184331fa3e55e52b890ea95e65ba581ae3429
 runc version: dc9208a3303feef5b3839f4323d9beb36df0a9dd
 init version: fec3683
 Security Options:
  apparmor
  seccomp
   Profile: default
 Kernel Version: 4.15.0-1065-aws
 Operating System: Ubuntu 18.04.4 LTS
 OSType: linux
 Architecture: x86_64
 CPUs: 1
 Total Memory: 983.7MiB
 Name: ip-172-31-25-47
 ID: CALI:Y7RD:PIX5:H3CD:K62C:IVJH:ASKJ:THDQ:77B7:66VB:JUJ3:5V27
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 Registry: https://index.docker.io/v1/
 Labels:
 Experimental: false
 Insecure Registries:
  127.0.0.0/8
 Live Restore Enabled: false