Skip to content

The devc goal is less tolerant of copying to a directory path missing a trailing '/' than docker build #1387

Open
@scottkurz

Description

@scottkurz

With liberty-maven-plugin v3.5.1, using the devc goal, a Dockerfile with line like:

COPY --chown=1001:0 /target/liberty/wlp/usr/servers/defaultServer/bootstrap.properties /config
will result in an error like:

[INFO] docker run --rm -p 9081:9080 -p 9444:9443 -p 56605:56605 -e WLP_DEBUG_SUSPEND=n -e WLP_DEBUG_ADDRESS=56605 -e WLP_DEBUG_REMOTE=y -v C:\ydosppa\application-stack-intro\target/.libertyDevc/apps:/config/apps -v C:\ydosppa\application-stack-intro\target/.libertyDevc/dropins:/config/dropins -v C:\ydosppa\application-stack-intro:/devmode -v C:\ydosppa\application-stack-intro\target\liberty\wlp\usr\servers\defaultServer/logs:/logs -v C:\Users\ScottKurz.m2\repository:/devmode-maven-cache -v C:\ydosppa\application-stack-intro//target/liberty/wlp/usr/servers/defaultServer/bootstrap.properties:/config --name liberty-dev-1 intro-dev-mode server debug defaultServer -- --io.openliberty.tools.projectRoot=/devmode
[ERROR] docker: Error response from daemon: OCI runtime create failed: container_linux.go:380: starting container process caused: process_linux.go:545: container init caused: rootfs_linux.go:76: mounting "/host_mnt/c/ydosppa/application-stack-intro/target/liberty/wlp/usr/servers/defaultServer/bootstrap.properties" to rootfs at "/config" caused: mount through procfd: not a directory: unknown: Are you trying to mount a directory onto a file (or vice-versa)? Check if the specified host path exists and is the expected type.
[ERROR] An error occurred while running the container: docker: Error response from daemon: OCI runtime create failed: container_linux.go:380: starting container process caused: process_linux.go:545: container init caused: rootfs_linux.go:76: mounting "/host_mnt/c/ydosppa/application-stack-intro/target/liberty/wlp/usr/servers/defaultServer/bootstrap.properties" to rootfs at "/config" caused: mount through procfd: not a directory: unknown: Are you trying to mount a directory onto a file (or vice-versa)? Check if the specified host path exists and is the expected type. RC=125
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 15.933 s
[INFO] Finished at: 2022-01-24T09:39:38-05:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal io.openliberty.tools:liberty-maven-plugin:3.5.1:devc (default-cli) on project intro: An error occurred while running the container: docker: Error response from daemon: OCI runtime create failed: container_linux.go:380: starting container process caused: process_linux.go:545: container init caused: rootfs_linux.go:76: mounting "/host_mnt/c/ydosppa/application-stack-intro/target/liberty/wlp/usr/servers/defaultServer/bootstrap.properties" to rootfs at "/config" caused: mount through procfd: not a directory: unknown: Are you trying to mount a directory onto a file (or vice-versa)? Check if the specified host path exists and is the expected type. RC=125 -> [Help 1]

Context

Reading the doc: https://docs.docker.com/engine/reference/builder/#copy
suggests that the trailing slash should be used, i.e. it should be:

COPY --chown=1001:0 /target/liberty/wlp/usr/servers/defaultServer/bootstrap.properties /config/

However it's worth noting that for me, on Win 10 at least, a plain docker build of the equivalent Dockerfile will handle the above just fine.

Since a natural way to get a handle on devc is to compare it with a docker build, I wonder if this could be confusing enough that it might be worth fixing?

Possible solution

Perhaps, since we're modifying the Dockerfile anyway, we add the trailing slash anyway and fix it for the user?

My info

Win 10

Docker version

$ docker version
Client:
 Cloud integration: v1.0.20
 Version:           20.10.10
 API version:       1.41
 Go version:        go1.16.9
 Git commit:        b485636
 Built:             Mon Oct 25 07:47:53 2021
 OS/Arch:           windows/amd64
 Context:           default
 Experimental:      true

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions