Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add files via upload (docker volume article) #28

Merged
merged 16 commits into from
May 29, 2024

Conversation

FireFrozen94
Copy link
Contributor

this article plain to explain how to use bind mounts in docker, in the particular example of building a log system

@ctmbl ctmbl force-pushed the FireFrozen94-patch-1 branch from d933a80 to d53d454 Compare April 12, 2024 19:46
ctmbl added 3 commits April 12, 2024 21:51
- add links to docker doc
- focus the artcile on volumes instead of bind mounts,
  while giving key resources about their differences
- highlight key information
@ctmbl ctmbl requested review from atxr and ZynoXelek April 12, 2024 21:06
@ctmbl
Copy link
Contributor

ctmbl commented Apr 12, 2024

hey @FireFrozen94 if you see this I've updated a bit the article I tjink it is ready for publishing 👍

@FireFrozen94
Copy link
Contributor Author

FireFrozen94 commented Apr 13, 2024 via email

Copy link
Contributor

@ZynoXelek ZynoXelek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Once this will be corrected, it seems good to be published to me!

src/content/posts/docker_volume_introduction.md Outdated Show resolved Hide resolved
src/content/posts/docker_volume_introduction.md Outdated Show resolved Hide resolved
Copy link
Contributor

@atxr atxr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting topic!
Few comments but the overall quality of your article is really good!

src/content/posts/docker_volume_introduction.md Outdated Show resolved Hide resolved
src/content/posts/docker_volume_introduction.md Outdated Show resolved Hide resolved
src/content/posts/docker_volume_introduction.md Outdated Show resolved Hide resolved
src/content/posts/docker_volume_introduction.md Outdated Show resolved Hide resolved
@ctmbl
Copy link
Contributor

ctmbl commented Apr 19, 2024

@atxr tks for your comments, when I read them I got the feeling that you were putting the finger where it huts 😆

But that's also for the best, to be honest I knew I was missing something about the distinction between volumes/bind mounts, you just gave me the opportunity to enlighten it and learn a bit more!

So let's dive into it (with further research and reading from me)!

DISCLAIMER:
What I expose here you might have already understood but it wasn't clear to me so I'll write it anyway 🙂

TLDR

What we're talking about in this blog aren't volumes at all (even if we use --volume) they are bind mounts, we're just naming them volumes because we're confusing both.

Volumes are not only managed by -v and bind mounts not only managed by --mount.
Flags names and usage are just very very confusing

Examples with -v but similar syntax is possible with --mount:

  • bind mount: docker run -v <path/to/host>:<path/to/cont>
  • named volume: docker run -v <pre-created or not volume name>:<path/to/cont>
  • anonymous volum: docker run -v <path/to/cont>

You'll see that even in docker's doc the naming is confusing

Differences between -v and --mount behavior
As opposed to bind mounts, all options for volumes are available for both --mount and -v flags.
Volumes used with services, only support --mount.

WTF

Detailed explanation

Actually there are 3 ways of sharing data in docker:

  • bind mounts
  • named volumes
  • anonymous volumes

Named volumes

They are a space which exists outside of the container, managed by docker (exist in /var/lib/docker/volumes but you should never write to it form host), and survives containers death.
They have a name.

Named volumes are created either with the docker volume subcommand or with docker run -v <some new volume name>:</path/in/cont> or similar with --mount syntax

about docker volume

about -v in volumes doc:

-v or --volume: Consists of three fields, separated by colon characters (:). The fields must be in the correct order, and the meaning of each field isn't immediately obvious.

  • In the case of named volumes, the first field is the name of the volume, and is unique on a given host machine. For anonymous volumes, the first field is omitted.

also here at Named Volumes section

Anonymous volumes

They are volumes too, only we don't give them a name.
Their only interest (to my understanding) is to share space across containers, because they have no name they cannot be easily reused.

They are created with docker run -v <path/in/cont> and then referred to (because they have no name) and shared with another container with docker run --volumes-from <first container id> or similar with --mount syntax

about their creation with -v:

-v or --volume: Consists of three fields, separated by colon characters (:). The fields must be in the correct order, and the meaning of each field isn't immediately obvious.

  • In the case of named volumes, the first field is the name of the volume, and is unique on a given host machine. For anonymous volumes, the first field is omitted.

example of --volumes-from

Bind mounts

Bind mounts are actually what we describe in the article, they are a file or folder existing on host (at another path than /var/lib/docker/*) that is shared with the container, they can also be shared across containers because they can be mounted several time (but I don't know if this is a good practice honestly).

They are created with docker run -v <path/to/host>:<path/to/cont> or similar with --mount syntax.

about -v in bind mounts doc:

-v or --volume: Consists of three fields, separated by colon characters (:). The fields must be in the correct order, and the meaning of each field is not immediately obvious.

  • In the case of bind mounts, the first field is the path to the file or directory on the host machine.

Ressources

docker doc:

Other sources:

@ctmbl
Copy link
Contributor

ctmbl commented Apr 19, 2024

@atxr What I've written above is almost a blog post in itself ahah

Sorry for the extensive writing, I just wanted to avoid any possible misunderstanding which would have necessarily lead to pointless debates.
If you don't feel like digging in the details just read the TLDR section it should be enough to explain what was missleading us in my previous version of the article.

In the end it was @FireFrozen94 who was right to speak about bind mounts in his article, they are nothing alike volume and I was wrong to confuse them.
We can confuse --volume and --mount but we can't confuse the concepts of volumes and bind mounts

I'll soon propose a version that should satisfy everyone

@atxr
Copy link
Contributor

atxr commented Apr 19, 2024

Don't worry I didn't dig dip enough to get all the details you just highlighted in your TLDR
I just spotted there was some misunderstanding about mounts and volumes that were "thrown under the carpet" 🧹
I'm glad it helped!
Looking forward the fix! 🧇

@ctmbl ctmbl added the new content Add new posts, resources, events, or any content label Apr 30, 2024
@ctmbl ctmbl requested review from ZynoXelek and atxr May 4, 2024 23:45
@ctmbl
Copy link
Contributor

ctmbl commented May 4, 2024

@atxr @ZynoXelek I finally found some time to propose an up-to-date and confusion-less (I hope) version of the article

Sorry @FireFrozen94 for the previous modifications which were partially wrong, my bad 😓

@ctmbl ctmbl had a problem deploying to deployment-dev May 22, 2024 17:04 — with GitHub Actions Failure
Copy link
Contributor

@atxr atxr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wonderful 🦄
Much clearer 💡

src/content/posts/docker_volume_introduction.md Outdated Show resolved Hide resolved
@ctmbl
Copy link
Contributor

ctmbl commented May 28, 2024

tks @atxr could You approve now? 🙂

Copy link
Contributor

@ZynoXelek ZynoXelek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is ready to be published now

@ctmbl ctmbl merged commit bac1717 into iScsc:main May 29, 2024
2 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new content Add new posts, resources, events, or any content
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants