Bind Mounts

  • Maps a host file or directory to a container file or directory
  • Basically just two locations pointing to the same file(s)
  • Again, skips UFS, and host files overwrite any in container
  • Can't use in Dockerfile, must be at container run
docker container run -v /Users/stefan/stuff:/path/container # (mac/linux)
docker container run -v //c/Users/stefan/stuff:/path/container # (windows)

Example

~> pwd
/code/uberapp/src/

~> ls -l
index.html

~> cat index.html
<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">

  <title>Uber file!</title>

</head>

<body>
  <h1>My Uber App that does nothing yet!</h1>
</body>
</html>

~> docker container run -d --name nginx -p 80:80 -v $(pwd):/usr/share/nginx/html nginx
da196ad5ff5e28310cb367ae94d15c19db43a166b32ce14670fe502599d22f2c

~> docker container exec -it nginx bash
root@da196ad5ff5e:/~> cd /usr/share/nginx/html
root@da196ad5ff5e:/usr/share/nginx/html~> ls
index.html

root@da196ad5ff5e:/usr/share/nginx/html~> exit
~> curl localhost
<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">

  <title>Uber file!</title>

</head>

<body>
  <h1>My Uber App that does nothing yet!</h1>
</body>
</html>

results matching ""

    No results matching ""