RUVIDEO
Поделитесь видео 🙏

Devops | Docker Tutorial | Volume vs Bind Mount смотреть онлайн

📁 Лайфстайл 👁️ 16 📅 04.12.2023

Should You Use the Volume or Mount Flag?

For passing in a host's folder into a container both flags do basically the same thing. So which one should you use?
If you’ve played with Docker a bit, you’ve probably seen the -v (--volume) flag. It comes in very handy for passing in the current directory into a running container.

For example, if you were developing a web application you would want to mount in your source code so that you can see your changes without having to rebuild the Docker image.

Setting up a volume the old way with docker run:
docker container run ... -v "$(pwd)":/myapp
docker container run --name test_container_volume -v "$(pwd)":/myapp debian

The left side of the : is the current directory on the host and the right side of the : is where it gets mounted into the container.

Setting up the same volume using the mount flag with docker run:
docker container run ... --mount type=bind,source="$(pwd)",target=/myapp
docker run -it --name test_container_mount --mount type=bind,source=$(pwd),target=/myapp debian
This does the same thing but it’s more explicit. Without knowing anything else about the command we can see it’s a bind mount that has both a source and a target.

This flag was introduced for non-Swarm based containers in v17.06.

How are they different?
The only difference is, using -v will create the bound folder on the Docker host if it doesn’t already exist where as using --mount will throw an error.

I actually like the behavior of --mount here because chances are when used in the above scenario, you would always expect the folder to exist on the Docker host.

Which one should you use?
Docker recommends using the --mount flag because it’s more explicit. I would tend to agree but in real world use cases, you’re probably using Docker Compose.

How can you use the new style with Docker Compose?
Compose doesn’t (yet?) have a mounts property but you can do it with the volumes property:

volumes:
- type: "bind"
source: "."
target: "/myapp"
With the old way you would have just set volumes: [".:/myapp"].

Notice the --mount flag uses key–value pairs separated by commas to specify the mount settings for this container, making it easier to see exactly what they're configuring. Also note that when using the ‑‑mount flag, the source folder must already exist on the container host. When using -v, if the directory does not exist, the command will create it automatically. If the directory does not exist when using ‑‑mount, Docker with throw an error.

Что делает видео по-настоящему запоминающимся? Наверное, та самая атмосфера, которая заставляет забыть о времени. Когда вы заходите на RUVIDEO, чтобы посмотреть онлайн «Devops | Docker Tutorial | Volume vs Bind Mount» бесплатно и без регистрации, вы рассчитываете на нечто большее, чем просто загрузку плеера. И мы это понимаем. Контент такого уровня заслуживает того, чтобы его смотрели в HD 1080, без дрожания картинки и бесконечного буферизации.

Честно говоря, Rutube сегодня — это кладезь уникальных находок, которые часто теряются в общем шуме. Мы же вытаскиваем на поверхность самое интересное. Будь то динамичный экшн, глубокий разбор темы от любимого автора или просто уютное видео для настроения — всё это доступно здесь бесплатно и без лишних формальностей. Никаких «заполните анкету, чтобы продолжить». Только вы, ваш экран и качественный поток.

Если вас зацепило это видео, не забудьте взглянуть на похожие материалы в блоке справа. Мы откалибровали наши алгоритмы так, чтобы они подбирали контент не просто «по тегам», а по настроению и смыслу. Ведь в конечном итоге, онлайн-кинотеатр — это не склад файлов, а место, где каждый вечер можно найти свою историю. Приятного вам отдыха на RUVIDEO!

Видео взято из открытых источников Rutube. Если вы правообладатель, обратитесь к первоисточнику.