DEV Community

martabakgosong
martabakgosong

Posted on

bind mount and volume

Bind mounts and volumes are both used in Docker to share data between the host machine and the container. However, there are some differences between the two: Bind Mounts:

  • Bind mounts allow you to mount a file or directory on the host machine into a container.
  • Bind mounts can be read-write or read-only.
  • Bind mounts can be used to share data between the host machine and the container.
  • Bind mounts can be used to share data between containers.
  • Bind mounts can be used to access host level resources.

Volumes:

  • Volumes are managed by Docker and are created and managed by Docker commands.
  • Volumes can be used to persist data.
  • Volumes can be shared between containers.
  • Volumes can be backed up and restored.
  • Volumes can be used to improve performance.

In summary, bind mounts are used to share data between the host machine and the container, while volumes are used to persist data and improve performance. Both bind mounts and volumes have their own use cases and can be used together to achieve the desired outcome.

Top comments (0)