How to mount a host directory in a Docker container

+1 vote

Hi Guys,

I have one directory in the local system. I want to mount the directory to Docker container. How to do that?

Dec 23, 2020 in Docker by akhtar
• 38,180 points
195 views

1 answer to this question.

0 votes

Hi@akhtar,

You can use the -v option in your docker run command. This facility is not available via Dockerfile.

$ docker run -t -i -v <host_dir>:<container_dir> ubuntu /bin/bash

To do with Dockerfile, you can use the ADD keyword in your script.

ADD . /path/inside/docker/container
answered Dec 23, 2020 by MD
• 95,140 points

Related Questions In Docker

+4 votes
4 answers

How To Access a Service on Host From a Docker Container?

Adding to kalgi's answer, You can also ...READ MORE

answered Oct 16, 2018 in Docker by lina
• 8,220 points

edited Oct 16, 2018 by lina 21,302 views
+1 vote
2 answers

How do I copy a file from docker container to host?

Here is a way which you can ...READ MORE

answered Aug 27, 2018 in Docker by Damon Salvatore
• 5,980 points
24,517 views
0 votes
1 answer

How to create a container and run images in docker?

Look for what all images you have ...READ MORE

answered Feb 22, 2019 in Docker by Kalgi
• 52,310 points
532 views
0 votes
1 answer

How to Backup, Restore or Migrate data volumes in a docker container?

Steps to Backup a container 1)     ...READ MORE

answered Jul 3, 2019 in Docker by Sirajul
• 59,050 points
10,651 views
+2 votes
1 answer
+2 votes
1 answer

Deploy Docker Containers from Docker Cloud

To solve this problem, I followed advice ...READ MORE

answered Sep 3, 2018 in AWS by Priyaj
• 58,100 points
1,123 views
+1 vote
1 answer

How to install packages in a Docker container?

Hi@akhtar, To install packages in a docker container, ...READ MORE

answered Apr 15, 2020 in Docker by MD
• 95,140 points
26,839 views
0 votes
1 answer

How can I connect a docker container to two docker networks that I have created?

Hi@akhtar, It's correct that the network argument of ...READ MORE

answered Mar 23, 2020 in Docker by MD
• 95,140 points
912 views