Use the DOCKER_SOCKET env var for the user container's balena socket mount

Instead of hardcoding balena.sock we use this variable since the path changes
with the balena -> balenaEngine rename.

We keep also mounting into balena.sock for backwards compatibility (even though
most tools should transparently use the DOCKER_HOST env var).

Change-type: minor
Signed-off-by: Pablo Carranza Velez <pablo@balena.io>
This commit is contained in:
Pablo Carranza Velez 2018-10-17 17:04:14 +02:00
parent 46535028c1
commit 31e730600d

View File

@ -323,9 +323,13 @@ export function addFeaturesFromLabels(
}
if (checkTruthy(service.config.labels['io.balena.features.balena-socket'])) {
service.config.volumes.push('/var/run/balena.sock:/var/run/balena.sock');
service.config.volumes.push(`${constants.dockerSocket}:${constants.dockerSocket}`);
if (service.config.environment['DOCKER_HOST'] == null) {
service.config.environment['DOCKER_HOST'] = 'unix:///var/run/balena.sock';
service.config.environment['DOCKER_HOST'] = `unix://${constants.dockerSocket}`;
}
// We keep balena.sock for backwards compatibility
if (constants.dockerSocket != '/var/run/balena.sock') {
service.config.volumes.push(`${constants.dockerSocket}:/var/run/balena.sock`);
}
}