WHITECOLOR
WHITECOLOR

Reputation: 26142

how to simply run image with volume

I using latest docker for windows beta (native).

I have a directory:

code.hs
Dockerfile

I want to create and image that will have this directory as mounted /app and run code there. Also I want changes I made on the host to this files (code.hs) be visible inside the container. So I do:

Dockerfile:

FROM haskell:7.10
WORKDIR /app
VOLUME .:/app
CMD ["ghci"] 

When I run:

docker build . -t my-test
docker run -it my-test bash

> #app - inside the container is empty

What am I doing wrong? How to get what I want?

Upvotes: 0

Views: 69

Answers (1)

VonC
VonC

Reputation: 1324537

Try instead:

That is, Dockerfile:

FROM haskell:7.10
VOLUME /app
WORKDIR /app
CMD ["ghci"]

As the doc mentions:

The host directory is, by its nature, host-dependent.
For this reason, you can’t mount a host directory from Dockerfile because built images should be portable.
A host directory wouldn’t be available on all potential hosts.

And:

docker run -it -v /full/path:/app my-test bash

Upvotes: 1

Related Questions