Skip to content

Commit

Permalink
bugfix: building docker images under Windows with WSL
Browse files Browse the repository at this point in the history
When Dockerfile is not on the root directory of the project, under Windows its relative path is resolved with backward slashes.
But Docker-desktop run through WSL (Windows Subsystem Linux) so it does not understand backward slashes.

Fix spotify#282
  • Loading branch information
Benoit Guerin committed Mar 20, 2021
1 parent 1c2d7ea commit 6d3f950
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,11 @@
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.nio.file.FileSystem;
import java.nio.file.FileSystems;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.List;
Expand Down Expand Up @@ -190,8 +193,8 @@ static String buildImage(@Nonnull DockerClient dockerClient,

final ArrayList<DockerClient.BuildParam> buildParameters = new ArrayList<>();
if (dockerfile != null) {
buildParameters.add(DockerClient.BuildParam.dockerfile(
contextDirectory.relativize(dockerfile)));
buildParameters.add(DockerClient.BuildParam.create("dockerfile",
contextDirectory.relativize(dockerfile).toString().replaceAll("\\\\", "/")));
}

final LoggingProgressHandler progressHandler = new LoggingProgressHandler(log, verbose);
Expand Down

0 comments on commit 6d3f950

Please sign in to comment.