TritonDataCenter / sdc-docker

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

Deploying Docker container with -p results in this error : #89

Closed Smithx10 closed 8 years ago

Smithx10 commented 8 years ago

docker --tls run -d --name=sonarr -p 8989:8989 linuxserver/sonarr docker: Error response from daemon: (InternalError) Internal error (943a70a0-56eb-11e6-99e2-f5333764c975).

(tritonhost:docker0) ~]# cat $(svcs -L docker) | bunyan .... [2016-07-31T07:04:38.310Z] ERROR: docker/63291 on 67b889ec-31b3-43e6-9ffe-1a4223e9b943: vmapi appears to have recovered and is responding to pings without error [2016-07-31T07:04:38.311Z] ERROR: docker/63291 on 67b889ec-31b3-43e6-9ffe-1a4223e9b943: imgapi appears to have recovered and is responding to pings without error [2016-07-31T07:04:38.312Z] ERROR: docker/63291 on 67b889ec-31b3-43e6-9ffe-1a4223e9b943: cnapi appears to have recovered and is responding to pings without error .... [2016-07-31T07:05:03.551Z] ERROR: docker/63291 on 67b889ec-31b3-43e6-9ffe-1a4223e9b943: Uncaught exception (req_id=1a801ba0-56ed-11e6-899d-571931585c97, account=52839745-d873-e75b-abc5-feab8ce09def, login=james, route=containercreate, req.remoteAddress=192.168.1.21, req.remotePort=53176) POST /v1.23/containers/create?name=test01 HTTP/1.1 host: 192.168.1.104:2376 user-agent: Docker-Client/1.11.2 (linux) content-length: 1453 content-type: application/json accept-encoding: gzip

AssertionError: opts.config.overlay.externalPool (string) is required
    at Object.addExternalNet [as func](/opt/smartdc/docker/lib/backends/sdc/containers.js:1964:24)
    at Object._onImmediate (/opt/smartdc/docker/node_modules/vasync/lib/vasync.js:213:20)
    at processImmediate [as _immediateCallback](timers.js:363:15)

...

[root@headnode (tritonhost) ~]# sdc-sapi /services/$docker_svc HTTP/1.1 200 OK Content-Type: application/json Content-Length: 1674 Date: Sun, 31 Jul 2016 07:08:33 GMT Connection: keep-alive

{ "uuid": "2f66fc44-33d7-49d1-af52-1520f6840db8", "name": "docker", "application_uuid": "5f06949a-f5a0-4a90-ad4e-882b81ff39dd", "params": { "billing_id": "0ae33ebc-c216-11e2-9b84-6f7e2a82bc36", "image_uuid": "cd63fed2-55ba-11e6-842b-47723477d817", "archive_on_delete": true, "delegate_dataset": true, "maintain_resolvers": true, "networks": [ { "name": "admin" }, { "name": "external", "primary": true } ], "firewall_enabled": false, "tags": { "smartdc_role": "docker", "smartdc_type": "core" } }, "metadata": { "SERVICE_NAME": "docker", "SERVICE_DOMAIN": "docker.tritonhost.tritonhost.com", "USE_TLS": true, "user-script": "#!/usr/bin/bash\n#\n# This Source Code Form is subject to the terms of the Mozilla Public\n# License, v. 2.0. If a copy of the MPL was not distributed with this\n# file, You can obtain one at http://mozilla.org/MPL/2.0/.\n#\n\n#\n# Copyright (c) 2014, Joyent, Inc.\n#\n\nexport PS4='[\D{%FT%TZ}] ${BASH_SOURCE}:${LINENO}: ${FUNCNAME[0]:+${FUNCNAME[0]}(): }'\n\nset -o xtrace\nset -o errexit\nset -o pipefail\n\n#\n# The presence of the /var/svc/.ran-user-script file indicates that the\n# instance has already been setup (i.e. the instance has booted previously).\n#\n# Upon first boot, run the setup.sh script if present. On all boots including\n# the first one, run the configure.sh script if present.\n#\n\nSENTINEL=/var/svc/.ran-user-script\n\nDIR=/opt/smartdc/boot\n\nif [[ ! -e ${SENTINEL} ]]; then\n if [[ -f ${DIR}/setup.sh ]]; then\n ${DIR}/setup.sh 2>&1 | tee /var/svc/setup.log\n fi\n\n touch ${SENTINEL}\nfi\n\nif [[ ! -f ${DIR}/configure.sh ]]; then\n echo \"Missing ${DIR}/configure.sh cannot configure.\"\n exit 1\nfi\n\nexec ${DIR}/configure.sh\n" }, "type": "vm" }

notmatt commented 8 years ago

Hi @Smithx10,

I suspect this was an oversight in recent changes for DOCKER-585. To confirm my suspicions, can you tell me if you have fabric networking enabled or not (I suspect not).

I'll have a fix for this tomorrow, which should get through code review on Monday. If it's particularly urgent for you, and you do not have fabrics enabled, you should be able to apply the following change (which has not been tested, use your best judgement if that's an appropriate risk):

In the docker zone, change this if statement in /opt/smartdc/docker/lib/backends/sdc/containers.js:

        function addExternalNet(_, cb) {
            if (publishingPorts(container) || opts.fabricRequireExternal) {
                assert.object(opts.config.overlay, 'opts.config.overlay');
                assert.string(opts.config.overlay.externalPool,
                    'opts.config.overlay.externalPool');

To this:

        function addExternalNet(_, cb) {
            if (opts.config.overlay.enabled && (publishingPorts(container) || opts.fabricRequireExternal)) {
                assert.object(opts.config.overlay, 'opts.config.overlay');
                assert.string(opts.config.overlay.externalPool,
                    'opts.config.overlay.externalPool');

Apologies for the inconvenience here.

notmatt commented 8 years ago

Tracking this internally as DOCKER-901.

Smithx10 commented 8 years ago

notmatt,

The current setup does not have overlay, I changed the if, and it's working. Let me know if I can help by creating some unit tests.

Thank You, Bruce Smith

notmatt commented 8 years ago

@Smithx10 many thanks for the confirmation!

We do have integration tests that should have caught this in cli-run-ports.test.js, but I neglected to run them with overlays both enabled and disabled (that aspect still needs to be automated). This one's on me, sorry again.

notmatt commented 8 years ago

Resolved by commit 8dd03e9.