Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for custom DOCKER_HOST mount #162

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 18 additions & 4 deletions packages/docker/src/dockerCommands/container.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,15 @@ export async function createContainer(
...(args.systemMountVolumes || [])
]
for (const mountVolume of mountVolumes) {
dockerArgs.push(
`-v=${mountVolume.sourceVolumePath}:${mountVolume.targetVolumePath}`
)
let sourceVolumePath = mountVolume.sourceVolumePath
if (
sourceVolumePath === '/var/run/docker.sock' &&
env.DOCKER_HOST &&
env.DOCKER_HOST.startsWith('unix://')
) {
sourceVolumePath = env.DOCKER_HOST.replace('unix://', '')
}
dockerArgs.push(`-v=${sourceVolumePath}:${mountVolume.targetVolumePath}`)
}
if (args.entryPoint) {
dockerArgs.push(`--entrypoint`)
Expand Down Expand Up @@ -413,9 +419,17 @@ export async function containerRun(
...(args.systemMountVolumes || [])
]
for (const mountVolume of mountVolumes) {
let sourceVolumePath = mountVolume.sourceVolumePath
if (
sourceVolumePath === '/var/run/docker.sock' &&
env.DOCKER_HOST &&
env.DOCKER_HOST.startsWith('unix://')
) {
sourceVolumePath = env.DOCKER_HOST.replace('unix://', '')
}
dockerArgs.push(`-v`)
dockerArgs.push(
`${mountVolume.sourceVolumePath}:${mountVolume.targetVolumePath}${
`${sourceVolumePath}:${mountVolume.targetVolumePath}${
mountVolume.readOnly ? ':ro' : ''
}`
)
Expand Down