TritonDataCenter / sdc-docker

Docker Engine for Triton
Mozilla Public License 2.0
182 stars 49 forks source link

(Validation) HostConfig.PortBindings: unknown protocol: must be tcp or udp #107

Open gbmeuk opened 7 years ago

gbmeuk commented 7 years ago

I believe we have found a divergence from standard docker here with this error.

The error is actually caused by using uppercase letters instead lowercase letters in the ports section of the docker-compose.yml file. For example:

    ports:
      - '8300-8302'
      - '8301-8302/udp'
      - '8600/udp'
      - '8600/tcp'
      - '8500'
      - '8400'
      - '53'

works but:

    ports:
      - '8300-8302'
      - '8301-8302/UDP'
      - '8600/UDP'
      - '8600/TCP'
      - '8500'
      - '8400'
      - '53'

fails with the stack trace:

    HTTP/1.1 422 Unprocessable Entity
    content-type: text/plain
    content-length: 113
    date: Thu, 12 Jan 2017 11:39:52 GMT
    x-request-id: d4f24530-d8bb-11e6-b654-49cf349ed3e4
    x-response-time: 30
    server: Triton/1.9.0 (linux)

    (Validation) HostConfig.PortBindings: unknown protocol: must be tcp or udp (d4f24530-d8bb-11e6-b654-49cf349ed3e4)
    --
    ValidationError: HostConfig.PortBindings: unknown protocol: must be tcp or udp
        at ValidationError._DockerBaseError (/opt/smartdc/docker/lib/errors.js:173:15)
        at new ValidationError (/opt/smartdc/docker/lib/errors.js:278:22)
        at assertPortBindings (/opt/smartdc/docker/lib/validate.js:292:19)
        at Server.validateCreateContainer (/opt/smartdc/docker/lib/validate.js:453:13)
        at next (/opt/smartdc/docker/node_modules/restify/lib/server.js:745:30)
        at f (/opt/smartdc/docker/node_modules/once/once.js:17:25)
        at parseJson (/opt/smartdc/docker/node_modules/restify/lib/plugins/json_body_parser.js:62:9)
        at Server.parseBody (/opt/smartdc/docker/node_modules/restify/lib/plugins/body_parser.js:78:13)
        at next (/opt/smartdc/docker/node_modules/restify/lib/server.js:745:30)
        at f (/opt/smartdc/docker/node_modules/once/once.js:17:25)

It's also logged at INFO level instead of ERROR [2017-01-12T11:39:52.481Z] INFO: docker/audit/99775 on 3bc1d32f-43da-4afe-b8a9-88726bf3d3c2: handled: 422 (req_id=d4f24530-d8bb-11e6-b654-49cf349ed3e4, account=1c7d5ff0-6c69-c5e2-b7d5-aa7853714fae, login=gaz, route=containercreate, audit=true, remoteAddress=192.168.77.193, remotePort=60631, latency=30, _audit=true, req.version=*)

This issue is not reproducible on Docker Engine