Low Orbit Flux Logo 2 D

Docker How To Bind Mount Local Directory

If you are looking for instructions on how to bind mount with Docker you have come to the right place. Fortunately this is easy.

You can bind mount a directory like this:


docker run -d --name test3 -v /src/data:/data ubuntu    

You can make it read only like this


docker run -d --name test4 -v /src/data:/data:ro ubuntu  # RO

Apparently, you can’t setup a bind mount in a Dockerfile but you can do it using Docker compose like this:


version: '3.1'

services:
  mycontainer:
    image: myimage
    build: .
    volumes:
      - './source/path:/data1'