Can't find files in container that were created when building the image

I’m trying to install the neo4j-graphql extension in a container built from the official neo4j image. Since the neo4j image is built on a JRE image, I couldn’t build the jar files using maven. I forked github/neo4j-graphql/neo4j-graphql with the goal of using docker to pre-build the package. I added the following Dockerfile to the root of the project.

FROM openjdk:8-jdk

# Install git and maven.
RUN apt-get update && apt-get install -y --no-install-recommends git maven

# Get the neo4j-graphql source.
RUN git clone https://github.com/neo4j-graphql/neo4j-graphql
WORKDIR neo4j-graphql
RUN git checkout 3.2

# Build the package.
RUN mvn clean package

I then ran the following.

$ docker build -t 'neo4j-graphql-dist' .
$ docker run -d -it -v $PWD/dist:/neo4j-graphql/target neo4j-graphql-dist

I expected to see the jar file(s) in dist locally. But as that wasn’t the case, I ran the following to view the container.

docker exec -it nostalgic_ardinghelli /bin/bash

Inside the container, ls /neo4j-graphql/target was empty.

When the image was built, I saw the following two logs.

[INFO] Building jar: /neo4j-graphql/target/neo4j-graphql-3.2.3.1-SNAPSHOT.jar
[INFO] Replacing /neo4j-graphql/target/neo4j-graphql-3.2.3.1-SNAPSHOT.jar with /neo4j-graphql/target/neo4j-graphql-3.2.3.1-SNAPSHOT-shaded.jar

So I fully expected to see a jar file in the /neo4j-graphql/target directory. Any clues as to why the jar file isn’t there or, if it is, why I’m not able to see it?

Thanks.

Solved
The neo4j-graphql/target directory didn’t exist and maven wasn’t able to create it due to permissions. I created the directory before building the package and the maven build was successful.

FROM openjdk:8-jdk

# Install git and maven.
RUN apt-get update && apt-get install -y --no-install-recommends git maven

# Get the neo4j-graphql source.
RUN git clone https://github.com/neo4j-graphql/neo4j-graphql
WORKDIR neo4j-graphql
RUN git checkout 3.2

# Must create the target directory before building the package into it.
RUN mkdir /neo4j-graphql/target

# Build the package.
RUN mvn clean package

Then, to get the jar files out of the container, I ran the container with:

$ docker build -t 'neo4j-graphql-dist' .
$ docker run --rm -i -v ${PWD}/dist:/var/tmp/dist neo4j-graphql-dist sh -s <<EOF
chown -v $(id -u):$(id -g) target/neo4j-graphql-*.jar
cp -va target/neo4j-graphql-*.jar /var/tmp/dist
EOF

This ran and removed the container immediately and copied the jar files into the volume, making them available on the host.