Skip to content

Commit 9531417

Browse files
authored
Merge pull request #735 from nextcloud-libraries/fix/docker-macos
2 parents 7b6c3db + 48f0e31 commit 9531417

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

lib/docker.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,13 +158,17 @@ export async function startNextcloud(branch = 'master', mountApp: boolean|string
158158
}],
159159
}
160160

161+
// On macOS we need to expose the port since the docker container is running within a VM
162+
const autoExposePort = process.platform === 'darwin'
163+
161164
const container = await docker.createContainer({
162165
Image: SERVER_IMAGE,
163166
name: getContainerName(),
164167
Env: [`BRANCH=${branch}`, 'APCU=1'],
165168
HostConfig: {
166169
Binds: mounts.length > 0 ? mounts : undefined,
167170
PortBindings,
171+
PublishAllPorts: autoExposePort,
168172
// Mount data directory in RAM for faster IO
169173
Mounts: [{
170174
Target: '/var/www/html/data',
@@ -335,6 +339,13 @@ export const stopNextcloud = async function() {
335339
export const getContainerIP = async function(
336340
container = getContainer()
337341
): Promise<string> {
342+
const containerInspect = await container.inspect()
343+
const hostPort = containerInspect.NetworkSettings.Ports['80/tcp']?.[0]?.HostPort
344+
345+
if (hostPort) {
346+
return `localhost:${hostPort}`
347+
}
348+
338349
let ip = ''
339350
let tries = 0
340351
while (ip === '' && tries < 10) {

0 commit comments

Comments
 (0)