Docker
Docker Fundamentals - Persisting Data

The Mount Option

PRO

The Mount Option

In some situations you will have to use --mount instead of --volume. This command can be more explicit, but therefore longer, because it requires a few key-value pairs:

  • type=: specifies the type of mount, like bind.
  • src=: provides the local path.
  • destination=: specifies the destination inside the container.
  • readonly: marks the file as read-only.

The full command will look something like this:

$ docker container run --mount type=bind,src="$(pwd)/myfile.html",destination=/var/www/html,readonly -p 80:80 nginx:latest