0

I'm fairly new to docker, but I'm trying to see if I can use it to build the frontend app for a project using it and take the built app and hand it off to another tool.

So ideally, I'd like to:

1) Setup environment using Dockerfile. 2) Run npm run build

What i'm not sure is how can I access the build folder from the container from my host?

My docker file is:

FROM kkarczmarczyk/node-yarn:latest WORKDIR /app ADD . /app RUN yarn --ignore-engines RUN yarn run build

Then I do: docker build -t build-app

From the prompts it looks like it builds properly, but I don't know how to get the built app from the container. Its building to a /dist folder on the container.

How can I access it from the host?

Genu
  • 1,094
  • 1
  • 9
  • 22

1 Answers1

0

You need to mount a volume to your host machine, which allows you to share that particular directory, bidirectional with the container.

You could do this something like

docker run -v <host-path>:<container-path> <image-id>

Refer this answer. docker mounting volumes on host

Community
  • 1
  • 1
Sebin Benjamin
  • 1,758
  • 2
  • 21
  • 45
  • The problem is that I run the npm build script from the dockerfile which means that when I run docker build, it will build my app. I can see in the console when I. Hold the docket image that it also runs the npm script, so I never actually run a docker container like you mention – Genu Feb 23 '17 at 18:32