docker / docker/cli

Stack deploy fails if "target" or "published" port is a string

Open
#1,073 9 comments 5 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

area/networking area/stack area/swarm kind/bug
Dominant language
Go
Stars
6.1k
Forks
2.2k
Avg merge
1d 15h
Merged PRs (30d)
43

Description

As reported by @ushuz https://github.com/docker/cli/issues/229#issuecomment-381066533

version: '3.4'
services:
    web:
        image: nginx:alpine
        ports:
          - published: '8080'
            target: 80

Deploying the above produces:

$ docker stack deploy -c docker-compose.yml hello

services.web.ports.0.published must be a integer

The same issue is present for target:

version: '3.4'
services:
    web:
        image: nginx:alpine
        ports:
          - published: 8080
            target: '80'
$ docker stack deploy -c docker-compose.yml hello 

services.web.ports.0.target must be a integer

Changing both to an integer makes this work:

version: '3.4'
services:
    web:
        image: nginx:alpine
        ports:
          - published: 8080
            target: 80
$ docker stack deploy -c docker-compose.yml hello 

Creating network hello_default
Creating service hello_web

Reproduced on:

Client:
 Version:      18.05.0-ce
 API version:  1.37
 Go version:   go1.9.5
 Git commit:   f150324
 Built:        Wed May  9 22:12:05 2018
 OS/Arch:      darwin/amd64
 Experimental: true
 Orchestrator: swarm

Server:
 Engine:
  Version:      18.05.0-ce
  API version:  1.37 (minimum version 1.12)
  Go version:   go1.10.1
  Git commit:   f150324
  Built:        Wed May  9 22:20:16 2018
  OS/Arch:      linux/amd64
  Experimental: true

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 by reproducing the quoted published and target port cases with the docker stack deploy command and trace the stack deploy port validation path. Done means both quoted numeric values are accepted like integer values, while invalid port values still fail; add or update coverage where the existing validation tests are located.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker, go
Domain
cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.