mirror of
https://github.com/balena-os/balena-supervisor.git
synced 2025-06-01 23:30:48 +00:00
Merge pull request #1497 from balena-io/1494-balena-socket
Mount docker socket under `/host/run` for services
This commit is contained in:
commit
fb9a73b3d6
@ -344,13 +344,19 @@ export async function addFeaturesFromLabels(
|
|||||||
? service.config.volumes.push('/lib/firmware:/lib/firmware')
|
? service.config.volumes.push('/lib/firmware:/lib/firmware')
|
||||||
: null,
|
: null,
|
||||||
'io.balena.features.balena-socket': () => {
|
'io.balena.features.balena-socket': () => {
|
||||||
|
service.config.volumes.push(
|
||||||
|
`${constants.dockerSocket}:${constants.containerDockerSocket}`,
|
||||||
|
);
|
||||||
|
|
||||||
|
// Maintain the /var/run mount for backwards compatibility
|
||||||
service.config.volumes.push(
|
service.config.volumes.push(
|
||||||
`${constants.dockerSocket}:${constants.dockerSocket}`,
|
`${constants.dockerSocket}:${constants.dockerSocket}`,
|
||||||
);
|
);
|
||||||
|
|
||||||
if (service.config.environment['DOCKER_HOST'] == null) {
|
if (service.config.environment['DOCKER_HOST'] == null) {
|
||||||
service.config.environment[
|
service.config.environment[
|
||||||
'DOCKER_HOST'
|
'DOCKER_HOST'
|
||||||
] = `unix://${constants.dockerSocket}`;
|
] = `unix://${constants.containerDockerSocket}`;
|
||||||
}
|
}
|
||||||
// We keep balena.sock for backwards compatibility
|
// We keep balena.sock for backwards compatibility
|
||||||
if (constants.dockerSocket !== '/var/run/balena.sock') {
|
if (constants.dockerSocket !== '/var/run/balena.sock') {
|
||||||
|
@ -11,6 +11,10 @@ const constants = {
|
|||||||
checkString(process.env.DATABASE_PATH) || '/data/database.sqlite',
|
checkString(process.env.DATABASE_PATH) || '/data/database.sqlite',
|
||||||
containerId: checkString(process.env.SUPERVISOR_CONTAINER_ID) || undefined,
|
containerId: checkString(process.env.SUPERVISOR_CONTAINER_ID) || undefined,
|
||||||
dockerSocket: process.env.DOCKER_SOCKET || '/var/run/docker.sock',
|
dockerSocket: process.env.DOCKER_SOCKET || '/var/run/docker.sock',
|
||||||
|
|
||||||
|
// In-container location for docker socket
|
||||||
|
// Mount in /host/run to avoid clashing with systemd
|
||||||
|
containerDockerSocket: '/host/run/balena-engine.sock',
|
||||||
supervisorImage:
|
supervisorImage:
|
||||||
checkString(process.env.SUPERVISOR_IMAGE) || 'resin/rpi-supervisor',
|
checkString(process.env.SUPERVISOR_IMAGE) || 'resin/rpi-supervisor',
|
||||||
ledFile:
|
ledFile:
|
||||||
|
@ -8,6 +8,7 @@ import {
|
|||||||
ServiceComposeConfig,
|
ServiceComposeConfig,
|
||||||
ServiceConfig,
|
ServiceConfig,
|
||||||
} from '../src/compose/types/service';
|
} from '../src/compose/types/service';
|
||||||
|
import * as constants from '../src/lib/constants';
|
||||||
|
|
||||||
const configs = {
|
const configs = {
|
||||||
simple: {
|
simple: {
|
||||||
@ -270,6 +271,30 @@ describe('compose/service', () => {
|
|||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should correctly handle io.balena.features.balena-socket label', async () => {
|
||||||
|
const service = await Service.fromComposeObject(
|
||||||
|
{
|
||||||
|
appId: 123456,
|
||||||
|
serviceId: 123456,
|
||||||
|
serviceName: 'foobar',
|
||||||
|
labels: {
|
||||||
|
'io.balena.features.balena-socket': '1',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{ appName: 'test' } as any,
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(service.config.volumes).to.include.members([
|
||||||
|
`${constants.dockerSocket}:${constants.dockerSocket}`,
|
||||||
|
`${constants.dockerSocket}:/host/run/balena-engine.sock`,
|
||||||
|
`${constants.dockerSocket}:/var/run/balena.sock`,
|
||||||
|
]);
|
||||||
|
|
||||||
|
expect(service.config.environment['DOCKER_HOST']).to.equal(
|
||||||
|
'unix:///host/run/balena-engine.sock',
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
describe('Ordered array parameters', () => {
|
describe('Ordered array parameters', () => {
|
||||||
it('Should correctly compare ordered array parameters', async () => {
|
it('Should correctly compare ordered array parameters', async () => {
|
||||||
const svc1 = await Service.fromComposeObject(
|
const svc1 = await Service.fromComposeObject(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user