Skip to content

Commit

Permalink
fix(core): declaring a volume binding overwrites default mount
Browse files Browse the repository at this point in the history
close #801
  • Loading branch information
tchiotludo committed Oct 24, 2022
1 parent 7465de2 commit 2d97382
Showing 1 changed file with 14 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import java.nio.file.Files;
import java.nio.file.Path;
import java.time.Duration;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
Expand Down Expand Up @@ -165,13 +166,15 @@ public RunResult run(
container.withWorkingDir(workingDirectory.toFile().getAbsolutePath());
}

List<Bind> binds = new ArrayList<>();


if (workingDirectory != null) {
hostConfig
.withBinds(new Bind(
workingDirectory.toAbsolutePath().toString(),
new Volume(workingDirectory.toAbsolutePath().toString()),
AccessMode.rw
));
binds.add(new Bind(
workingDirectory.toAbsolutePath().toString(),
new Volume(workingDirectory.toAbsolutePath().toString()),
AccessMode.rw
));
}

if (abstractBash.getDockerOptions().getUser() != null) {
Expand All @@ -187,13 +190,17 @@ public RunResult run(
}

if (this.volumesEnabled && abstractBash.getDockerOptions().getVolumes() != null) {
hostConfig.withBinds(runContext.render(abstractBash.getDockerOptions().getVolumes())
binds.addAll(runContext.render(abstractBash.getDockerOptions().getVolumes())
.stream()
.map(Bind::parse)
.collect(Collectors.toList())
);
}

if (binds.size() > 0) {
hostConfig.withBinds(binds);
}

if (abstractBash.getDockerOptions().getDeviceRequests() != null) {
hostConfig.withDeviceRequests(abstractBash.getDockerOptions()
.getDeviceRequests()
Expand Down

0 comments on commit 2d97382

Please sign in to comment.