Reputation: 530
I want to access an external directory 'web-app' in my docker container.
Consider the directory structure below:
MyDcocker
|-dockerFile
|-web-app
|-flask-web.py
I have the following lines in my dockerfile:
VOLUME ["web-app"]
# Run flask-web (API) file
CMD ["python3","web-app/flask-web.py"]
When running the image, I get the error:
python3: can't open file 'web-app/flask-web.py': [Errno 2] No such file or directory
I believe the directory has not been mounted properly. How do I solve this ?
Upvotes: 2
Views: 2392
Reputation: 4754
You will write in Dockerfile how you build the container, not how container will interact with your host.
For mount a directory from your host in your container, you have 2 solutions :
with docker command line :
docker run -v $(pwd)/web-app:/var/lib/web-app/ dck-image-name
with docker-compose
version: '2'
services:
myservice:
image: dck-image-name
volumes:
- ./web-app:/var/lib/web-app/
Upvotes: 4