Docker build Share data with host

460 Views Asked by At

I hava a custom Dockerfile that setup and builds a project of mine. But now I haven't beeing able to place that into a folder of the host. Here the script and docker file...

Command

sudo docker build --output type=local,dest=./build/server/server -f ./build/scripts/Dockerfile.server ./server

Dockerfile

FROM node:14 AS build-stage

WORKDIR /usr/src/project
RUN npm i [email protected] -g
COPY package*.json ./
RUN npm install --only=production
COPY . .
RUN nexe server.js -t linux-x64-12.14.1

FROM scratch AS export-stage
COPY --from=build-stage /usr/src/project/server /
1

There are 1 best solutions below

7
On BEST ANSWER

The docker buildkit needs to be enabled before running the build command:

export DOCKER_BUILDKIT=1

You are setting up the context wrong. The command should be:

sudo docker build --output type=local,dest=./build/server/server -f ./build/scripts/Dockerfile.server .

The dot at the end sets the build context to current directory structure.