docker / docker/cli

Docker Swarm deploy with array failed message

Open
#5,159 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

kind/bug status/0-triage
Dominant language
Go
Stars
6.1k
Forks
2.2k
Avg merge
1d 15h
Merged PRs (30d)
43

Description

Description

Hi,
I'm trying to deploy service dynamically under docker swarm mode by docker compose yml and some variables. Here's my docker compose yml ↓

version: '3.9'

services:
  web:
    build: ./sta_server
    restart: unless-stopped
    container_name: ${container_name} 
    environment:
      - serviceRootUrl=${serviceRootUrl}
      - http_cors_enable=${http_cors_enable}
      - http_cors_allowed.origins=*
      - persistence_db_driver=${persistence_db_driver}
      - persistence_db_username=${POSTGRES_USER}
      - persistence_db_password=${POSTGRES_PASSWORD}
      - persistence_db_url=${persistence_db_url}
      - persistence_autoUpdateDatabase=${persistence_autoUpdateDatabase}
    ports:
      - ${TOMCAT_PORTS_LOCAL}:${TOMCAT_PORTS_VIRTUAL}
      - ${TCP_PORTS_LOCAL}:${TCP_PORTS_VIRTUAL}
    depends_on:
      - test_swarm2_PG_ALIAS
    networks:
      - test_overlay_network
      
  test_swarm2_PG_ALIAS:
    image: postgis/postgis:latest
    restart: unless-stopped
    container_name: ${PGContainer_name}
    environment:
      - POSTGRES_DB=${POSTGRES_DB}
      - POSTGRES_USER=${POSTGRES_USER}
      - POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
      - PGDATA=/tmp
      - POSTGRES_HOST_AUTH_METHOD=${POSTGRES_HOST_AUTH_METHOD}
      - POSTGRES_INITDB_ARGS=${POSTGRES_INITDB_ARGS}
    ports:
        - ${PG_PORTS_LOCAL}:${PG_PORTS_VIRTUAL}
    volumes:
      - postgis_volume:/var/lib/postgresql/data/test_swarm2_PG_ALIAS
    networks:
      - test_overlay_network
      
volumes:
    postgis_volume:
networks:
  test_overlay_network:
    external: true

And when I execute docker stack deploy -c docker-compose.yml test_swarm2_stack I got some strange error ↓
services.web.ports array items[0,1] must be unique
Not sure if there's an issue with my yml.

Reproduce
  1. create yml
  2. docker stack deploy -c docker-compose.yml test_swarm2_stack
Expected behavior

No response

docker version
Client:
 Cloud integration: v1.0.35+desktop.13
 Version:           26.1.1
 API version:       1.45
 Go version:        go1.21.9
 Git commit:        4cf5afa
 Built:             Tue Apr 30 11:44:56 2024
 OS/Arch:           darwin/arm64
 Context:           desktop-linux

Server: Docker Desktop 4.30.0 (149282)
 Engine:
  Version:          26.1.1
  API version:      1.45 (minimum version 1.24)
  Go version:       go1.21.9
  Git commit:       ac2de55
  Built:            Tue Apr 30 11:48:04 2024
  OS/Arch:          linux/arm64
  Experimental:     false
 containerd:
  Version:          1.6.31
  GitCommit:        e377cd56a71523140ca6ae87e30244719194a521
 runc:
  Version:          1.1.12
  GitCommit:        v1.1.12-0-g51d5e94
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0
docker info
Client:
 Version:    26.1.1
 Context:    desktop-linux
 Debug Mode: false
 Plugins:
  buildx: Docker Buildx (Docker Inc.)
    Version:  v0.14.0-desktop.1
    Path:     /Users/user/.docker/cli-plugins/docker-buildx
  compose: Docker Compose (Docker Inc.)
    Version:  v2.27.0-desktop.2
    Path:     /Users/user/.docker/cli-plugins/docker-compose
  debug: Get a shell into any image or container (Docker Inc.)
    Version:  0.0.29
    Path:     /Users/user/.docker/cli-plugins/docker-debug
  dev: Docker Dev Environments (Docker Inc.)
    Version:  v0.1.2
    Path:     /Users/user/.docker/cli-plugins/docker-dev
  extension: Manages Docker extensions (Docker Inc.)
    Version:  v0.2.23
    Path:     /Users/user/.docker/cli-plugins/docker-extension
  feedback: Provide feedback, right in your terminal! (Docker Inc.)
    Version:  v1.0.4
    Path:     /Users/user/.docker/cli-plugins/docker-feedback
  init: Creates Docker-related starter files for your project (Docker Inc.)
    Version:  v1.1.0
    Path:     /Users/user/.docker/cli-plugins/docker-init
  sbom: View the packaged-based Software Bill Of Materials (SBOM) for an image (Anchore Inc.)
    Version:  0.6.0
    Path:     /Users/user/.docker/cli-plugins/docker-sbom
  scout: Docker Scout (Docker Inc.)
    Version:  v1.8.0
    Path:     /Users/user/.docker/cli-plugins/docker-scout

Server:
 Containers: 10
  Running: 5
  Paused: 0
  Stopped: 5
 Images: 150
 Server Version: 26.1.1
 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: 2
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local splunk syslog
 Swarm: active
  NodeID: iv084svjmpm6jbob8sbe3xdt5
  Is Manager: true
  ClusterID: x5ay8bp6cpryphn80vzaewi5e
  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: io.containerd.runc.v2 runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: e377cd56a71523140ca6ae87e30244719194a521
 runc version: v1.1.12-0-g51d5e94
 init version: de40ad0
 Security Options:
  seccomp
   Profile: unconfined
  cgroupns
 Kernel Version: 6.6.26-linuxkit
 Operating System: Docker Desktop
 OSType: linux
 Architecture: aarch64
 CPUs: 8
 Total Memory: 7.657GiB
 Name: docker-desktop
 ID: 85a253ff-05c0-46ff-aa73-8d1a46b70a88
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 HTTP Proxy: http.docker.internal:3128
 HTTPS Proxy: http.docker.internal:3128
 No Proxy: hubproxy.docker.internal
 Labels:
  com.docker.desktop.address=unix:///Users/user/Library/Containers/com.docker.docker/Data/docker-cli.sock
 Experimental: false
 Insecure Registries:
  hubproxy.docker.internal:5555
  127.0.0.0/8
 Live Restore Enabled: false

WARNING: daemon is not using the default seccomp profile
Additional Info

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the supplied docker-compose.yml, especially services.web.ports, and reproduce the validation from docker stack deploy -c docker-compose.yml test_swarm2_stack. Trace how the resolved port values are checked for uniqueness; done means identifying whether the reported error is a CLI bug or an invalid configuration and covering the confirmed behavior with an appropriate regression test.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker, docker-compose
Domain
cli, devops
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.