From dd2a806ab8d21f3bffae2bf8e5fbf9de90ac204b Mon Sep 17 00:00:00 2001 From: Girish Ramakrishnan Date: Fri, 23 Oct 2015 16:10:54 -0700 Subject: [PATCH] Do not set hostname of app container Some apps like pasteboard try to curl the public app url from inside the container. This fails because we set the hostname and the hostname maps to the internal docker IP. To fix this, simply export two environment variables providing the app's domain and origin. The hostname is set to the app location instead of the FQDN for debugging. Fixes #521 --- src/docker.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/docker.js b/src/docker.js index 50677bc8d..96947414d 100644 --- a/src/docker.js +++ b/src/docker.js @@ -129,8 +129,10 @@ function createSubcontainer(app, cmd, callback) { var exposedPorts = {}, dockerPortBindings = { }; var stdEnv = [ 'CLOUDRON=1', - 'WEBADMIN_ORIGIN' + '=' + config.adminOrigin(), - 'API_ORIGIN' + '=' + config.adminOrigin() + 'WEBADMIN_ORIGIN=' + config.adminOrigin(), + 'API_ORIGIN=' + config.adminOrigin(), + 'APP_ORIGIN=https://' + config.appFqdn(app.location), + 'APP_DOMAIN=' + config.appFqdn(app.location) ]; // docker portBindings requires ports to be exposed @@ -155,7 +157,8 @@ function createSubcontainer(app, cmd, callback) { if (error) return callback(new Error('Error getting addon environment : ' + error)); var containerOptions = { - Hostname: config.appFqdn(app.location), + // do _not_ set hostname to app fqdn. doing so sets up the dns name to look up the internal docker ip. this makes curl from within container fail + Hostname: semver.gte(targetBoxVersion(app.manifest), '0.0.77') ? app.location : config.appFqdn(app.location), Tty: isAppContainer, Image: app.manifest.dockerImage, Cmd: cmd,