Class DockerPathUtil


  • public class DockerPathUtil
    extends Object
    Docker path resolution and manipulation utility methods.

    This class provides methods for manipulating paths as they appear in docker-compose or Dockerfiles. This class does not provide for generic path manipulation across platforms or file systems. Paths that appear in Docker configurations use forward slash as a separator character, so this class makes no provisions for handling Windows platform path semantics (e.g. the presence of drive letters or backward slash).

    • Constructor Detail

      • DockerPathUtil

        public DockerPathUtil()
    • Method Detail

      • resolveAbsolutely

        public static File resolveAbsolutely​(String pathToResolve,
                                             String baseDir)
        Resolves the supplied resource (a path or directory on the filesystem) relative the supplied baseDir. The returned File is guaranteed to be absolute. The returned file is not guaranteed to exist.

        If the supplied pathToResolve is already absolute, then it is returned unmodified. Otherwise, the pathToResolve is returned as an absolute File using the supplied baseDir as its parent.

        Parameters:
        pathToResolve - represents a filesystem resource, which may be an absolute path
        baseDir - the absolute path used to resolve non-absolute path resources; must be absolute
        Returns:
        an absolute File reference to pathToResolve; not guaranteed to exist
        Throws:
        IllegalArgumentException - if the supplied baseDir does not represent an absolute path