mirror of
https://github.com/danbulant/docker-compose
synced 2026-06-24 09:22:08 +00:00
fix: fix mapping ipv6-based port mappings
This commit is contained in:
parent
e7013dfab1
commit
48c9f0841a
3 changed files with 41 additions and 43 deletions
|
|
@ -10,8 +10,6 @@ const mapPorts = (
|
||||||
return ports.split(',').map((untypedPort) => {
|
return ports.split(',').map((untypedPort) => {
|
||||||
const exposedFragments = untypedPort.trim().split('->')
|
const exposedFragments = untypedPort.trim().split('->')
|
||||||
|
|
||||||
console.log(exposedFragments)
|
|
||||||
|
|
||||||
const [port, protocol] =
|
const [port, protocol] =
|
||||||
exposedFragments.length === 1
|
exposedFragments.length === 1
|
||||||
? exposedFragments[0].split('/')
|
? exposedFragments[0].split('/')
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ import Docker from 'dockerode'
|
||||||
import * as compose from '../src/index'
|
import * as compose from '../src/index'
|
||||||
import * as path from 'path'
|
import * as path from 'path'
|
||||||
import { readFile } from 'fs'
|
import { readFile } from 'fs'
|
||||||
import { mapPorts, mapPsOutput } from '../src/index'
|
import { mapPsOutput } from '../src/index'
|
||||||
const docker = new Docker()
|
const docker = new Docker()
|
||||||
|
|
||||||
// Docker commands, especially builds, can take some time. This makes sure that they can take the time they need.
|
// Docker commands, especially builds, can take some time. This makes sure that they can take the time they need.
|
||||||
|
|
@ -94,25 +94,21 @@ test('ensure exit code is returned correctly', async (): Promise<void> => {
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('starts containers properly with --build and --timeout options', (): void => {
|
describe('starts containers properly with --build and --timeout options', (): void => {
|
||||||
beforeEach(
|
beforeEach(async (): Promise<void> => {
|
||||||
async (): Promise<void> => {
|
|
||||||
await compose.down({
|
await compose.down({
|
||||||
cwd: path.join(__dirname),
|
cwd: path.join(__dirname),
|
||||||
log: logOutput,
|
log: logOutput,
|
||||||
config: 'docker-compose-build.yml'
|
config: 'docker-compose-build.yml'
|
||||||
})
|
})
|
||||||
}
|
})
|
||||||
)
|
|
||||||
|
|
||||||
afterEach(
|
afterEach(async (): Promise<void> => {
|
||||||
async (): Promise<void> => {
|
|
||||||
await compose.down({
|
await compose.down({
|
||||||
cwd: path.join(__dirname),
|
cwd: path.join(__dirname),
|
||||||
log: logOutput,
|
log: logOutput,
|
||||||
config: 'docker-compose-build.yml'
|
config: 'docker-compose-build.yml'
|
||||||
})
|
})
|
||||||
}
|
})
|
||||||
)
|
|
||||||
|
|
||||||
test('ensure container gets started with --build option', async (): Promise<void> => {
|
test('ensure container gets started with --build option', async (): Promise<void> => {
|
||||||
await compose.upAll({
|
await compose.upAll({
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import mapPorts from "../src/port-mapper";
|
import mapPorts from '../src/port-mapper'
|
||||||
|
|
||||||
test('map ports for empty string', () => {
|
test('map ports for empty string', () => {
|
||||||
expect(mapPorts('')).toEqual([])
|
expect(mapPorts('')).toEqual([])
|
||||||
|
|
@ -33,22 +33,26 @@ test('map multiple tcp ports exposed on ivp4 interfaces', () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
test('map multiple tcp ports exposed on ipv4 and ipv6 interfaces', () => {
|
test('map multiple tcp ports exposed on ipv4 and ipv6 interfaces', () => {
|
||||||
expect(mapPorts('0.0.0.0:443->443/tcp,:::443->443/tcp, 0.0.0.0:80->80/tcp,:::80->80/tcp')).toEqual([
|
expect(
|
||||||
|
mapPorts(
|
||||||
|
'0.0.0.0:443->443/tcp,:::443->443/tcp, 0.0.0.0:80->80/tcp,:::80->80/tcp'
|
||||||
|
)
|
||||||
|
).toEqual([
|
||||||
{
|
{
|
||||||
exposed: { port: 443, protocol: 'tcp' },
|
exposed: { port: 443, protocol: 'tcp' },
|
||||||
mapped: { address: '0.0.0.0', port: 443 },
|
mapped: { address: '0.0.0.0', port: 443 }
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
exposed: { port: 443, protocol: 'tcp' },
|
exposed: { port: 443, protocol: 'tcp' },
|
||||||
mapped: { address: ':::', port: 443 },
|
mapped: { address: ':::', port: 443 }
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
exposed: { port: 80, protocol: 'tcp' },
|
exposed: { port: 80, protocol: 'tcp' },
|
||||||
mapped: { address: '0.0.0.0', port: 80 },
|
mapped: { address: '0.0.0.0', port: 80 }
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
exposed: { port: 80, protocol: 'tcp' },
|
exposed: { port: 80, protocol: 'tcp' },
|
||||||
mapped: { address: ':::', port: 80 },
|
mapped: { address: ':::', port: 80 }
|
||||||
},
|
}
|
||||||
])
|
])
|
||||||
})
|
})
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue