- [Instructor] If we do a docker container run -d
and use the --mount option,
the source needs to be a specific folder,
and actually we use an equals sign there, comma
and then the target is going to be,
again, a specific folder.
We'll start nginx,
but we missed an important parameter here.
The type needs to be bind,
and you actually put a comma right there
between the type=bind and the source.
So that's the format.
Let's push enter, and we get an invalid mount configuration
for the type bind.
It tells us the bind source path does not exist.
So this is actually an important point here
about bind mounts and the difference
between bind mounts and volumes.
With volumes, we didn't have to create the volume
ahead of time.
We can simply start a container
and say we wanna mount a volume called XYZ,
and XYZ will be automatically created for us.
With bind mounts, you have to create the folder
or the source, which will be mounted
by the container that's using the bind mount.
So let's do an up arrow in this,
and let's actually try /tmp.
Surely there's a tmp directory already on this Linux host.
And there we go.
So we mounted tmp in the target called /app
inside this nginx web server that we just started up
as a new container using a bind mount.
So that's how easy it is to start up containers
using bind mounts.
You just have to know some of the quirkiness
of how bind mounts work.
But, again, you're always recommended
to use volumes over bind mounts.