Sign inSign up

zsp10/volumes

By zsp10

•Updated about 4 years ago

messing around with volumes and bind-mount

Image
0

879

zsp10/volumes repository overview

⁠Docker_Volumes

⁠APIs

  • http://localhost:3000
  • http://localhost:3000/feedback/<title_name>.txt

⁠Named Volumes:

docker run -v feedy:/app/feedback -d -p 3000:80 --rm --name deep zsp10/volumes

  • Can be accessed by multiple containers.<feedy - volume name>

⁠Anonymous Volumes:

docker run -v /app/feedback -d -p 3000:80 --rm --name deep zsp10/volumes

  • Can be accessed by single container , gets removed along if the container is deleted/removed

⁠Bind Mounts:

docker run -v "$(pwd):/app" -v feedy:/app/feedback -d -p 3000:80 --rm --name deep zsp10/volumes

  • Might cause error, if you don't have node_modules in the host machine, one way to avoid this is by creating an anonymous volume out of the node_modules from the container itself i.e -v app/node_modules
    • docker run -v "$(pwd):/app" -v app/node_modules -v feedy:/app/feedback -d -p 3000:80 --rm --name deep zsp10/volumes

⁠Adding Read-Only property for bind-mount

  • "ro" for read-only
    • docker run -v "$(pwd):/app:ro" -v app/node_modules -v app/temp -v feedy:/app/feedback -d -p 3000:80 --rm --name deep zsp10/volumes

⁠Env and Args

  • docker pull zsp10/volumes:dev
  • use "-e" flag to add env variables, as shown below
    • docker run -d -p 3000:8000 --name deep -e PORT=8000 zsp10/volumes:dev
  • Can also link .env file, as shown below
    • docker run -d -p 3000:8080 --name deep --env-file .env --rm zsp10/volumes:dev

Tag summary

Content type

Image

Digest

Size

356.2 MB

Last updated

about 4 years ago

docker pull zsp10/volumes