[HN Gopher] Bocker: Docker implemented in around 100 lines of Ba...
       ___________________________________________________________________
        
       Bocker: Docker implemented in around 100 lines of Bash (2015)
        
       Author : begoon
       Score  : 101 points
       Date   : 2022-10-15 20:00 UTC (2 hours ago)
        
 (HTM) web link (github.com)
 (TXT) w3m dump (github.com)
        
       | encryptluks2 wrote:
       | Just because you can doesn't mean you should.
        
         | wmf wrote:
         | You shouldn't replace Docker with a shell script but you should
         | understand (at some level) how Docker works. Unfortunately this
         | code is pretty dense so it would probably take a while to
         | untangle it.
        
           | LaLaLand122 wrote:
           | > You shouldn't replace Docker with a shell script
           | 
           | True. You should replace it with podman!
        
       | n4bz0r wrote:
       | Woah! Don't know if it can be used as a proper Docker replacement
       | (probably not), but I sure do appreciate the project as an
       | example of how to use all the tools to implement an isolated
       | environment. And the fact that it actually works with Docker
       | containers (well, why wouldn' it, but still) is just a cheery on
       | top!
        
         | rtlfe wrote:
         | > Don't know if it can be used as a proper Docker replacement
         | 
         | The readme says "I can make no guarantees that it won't trash
         | your system", so yeah clearly not intended for real use.
        
           | stjohnswarts wrote:
           | that's why smart people always check this stuff out on spare
           | machines and VMs.
           | 
           | Right?
           | 
           | ... right?
        
           | jen20 wrote:
           | Most software says that in the license too (even commercial
           | software!) so it's nice to see it front and center for once.
        
         | puchatek wrote:
         | A cheer for the cheery!
        
       | awinter-py wrote:
       | follow up blogpost 'reimplementing 100 lines of bash in 1 million
       | lines of go as resume building exercise'
        
         | DrewADesign wrote:
         | Then a level 79 Unix beard reimplements it in 40 inscrutable
         | lines of Perl in the shape of an ascii whale... But can't
         | figure out how it works an hour later.
        
           | awinter-py wrote:
           | =for comment       keep the ascii whale swimming       do not
           | modify this code       =cut
        
         | [deleted]
        
       | dang wrote:
       | Related:
       | 
       |  _Bocker - Docker implemented in around 100 lines of Bash (2015)_
       | - https://news.ycombinator.com/item?id=22244706 - Feb 2020 (196
       | comments)
       | 
       |  _Docker implemented in around 100 lines of bash_ -
       | https://news.ycombinator.com/item?id=16453610 - Feb 2018 (9
       | comments)
       | 
       |  _Show HN: Bocker - Docker implemented in 100 lines of bash_ -
       | https://news.ycombinator.com/item?id=9925896 - July 2015 (87
       | comments)
        
       | ohiovr wrote:
       | 8,800 stars!
        
         | throwaway892238 wrote:
         | Why do people care about github stars?
        
           | ohiovr wrote:
           | Because people have hobbies and wish other people are
           | enjoying them. Or it does help people tell if code is helpful
           | if more people are using it. Or its some guy with 8,800 throw
           | away android phones.
        
           | osrec wrote:
           | The same reason why people care about likes on Facebook or
           | karma on HN.
           | 
           | Internet points mean very little, until you get enough that
           | you start floating to the top of popularity rankings, at
           | which point they suddenly become indirectly monetizable.
        
             | version_five wrote:
             | Stars have some value in they at least let you see that
             | (the potential for funny business aside) many people have
             | looked at the repo and upvoted it for whatever reason. I'm
             | sure there are buggy or otherwise sketchy repos with many
             | stars, and various gems with few stars (I have some :p ),
             | though overall it's a signal
             | 
             | Incidentally karma on HN is similar to the extent that it
             | lets you how active a participant someone is, and that
             | they're not a troll or throwaway. Again, it can certainly
             | be gamed, and throwaway accounts often add valuable
             | comments, but its still a signal
        
             | moomin wrote:
             | I've been contacted more than once by recruiters who've
             | been attracted by stars of my profile. It's always a little
             | challenging to explain to them that my profile is just my
             | hobbies.
        
       | ajross wrote:
       | Really this is more interesting as a great tutorial on the way
       | Linux container tools work (and especially their fundamental
       | simplicity -- the docs make them seem scary when they really
       | aren't) more than it is as a docker replacement (docker is
       | obviously much larger than this one script, but not really
       | "large" as a software stack).
       | 
       | But reading this makes clear that, yes, containers are just
       | filesystem trees, network namespaces are just like internal
       | networks maintained by straightforward commands underneath an "ip
       | netns" command, etc...
       | 
       | Great stuff.
        
       | smoldesu wrote:
       | Liz Rice's presentation on re-creating Docker in Go is also quite
       | eye-opening: https://www.youtube.com/watch?v=Utf-A4rODH8
        
         | version_five wrote:
         | Yes agreed, as someone who had basically no understanding of
         | what docker does, this was very helpful (I'm pretty sure I saw
         | it because docker used it as an introduction to itself on their
         | site)
        
       | sakras wrote:
       | This is amazing! Does GitHub allow emoji names? I'd love it to be
       | called ocker
        
         | nkrisc wrote:
         | Why do you need an emoji for the letter 'B'?
        
           | teaearlgraycold wrote:
           | That emoji exists because of the blood type.
           | 
           | 
           | There was a meme a while back where people would use  all
           | over the place. Not sure why it was funny but it was.
        
             | ghostly_s wrote:
             | If you have to explain it, it's not funny. Particularly
             | when the knowyourmeme page seems to indicate it's most
             | prominently used by racists.
        
               | oaththrowaway wrote:
               | I see no mention of the word racist on that page. Can you
               | point it out?
        
             | stjohnswarts wrote:
             | I think it was popular because of reaking ad
        
             | nkrisc wrote:
             | That's not what I'm asking. I was asking why they need an
             | emoji to write "Bocker"
        
               | teaearlgraycold wrote:
               | It's a meme
        
           | NavinF wrote:
           | https://knowyourmeme.com/memes/b-button-emoji-
        
       | chubot wrote:
       | It looks like it relies on BtrFS? Can anyone add support for
       | OverlayFS 2? :) which I think is more deployed these days due to
       | Docker itself
       | 
       | I'd be curious to see how it looks
        
         | loxias wrote:
         | I, too, wanted something like that and wrote it, in bash. :)
         | Can confirm it's just as easy to do as you'd expect, and works
         | quite well.
        
           | chubot wrote:
           | Link?
        
         | ajross wrote:
         | With overlays, you'd need some kind of registry of all the
         | images in the underlying filesystem. Btrfs subvolumes give that
         | to you for free, essentially. No need for deciding where to put
         | them, just give them a name.
        
           | loxias wrote:
           | Or you could treat the final image for the container as the
           | read only base for the overlay. That's what I do. I "flatten"
           | the image from buildkit, and untar it to a directory. Then
           | make an overlay mount for the container and chroot inside. :)
        
             | ajross wrote:
             | Right, but the point is a btrfs snapshot does that for you.
             | No need for a "flattening" step, just make a copy-on-write
             | snapshot of your layer at whatever state it exists in and
             | go. Delete the original later, etc... Doesn't matter.
        
         | jamal-kumar wrote:
         | It's like 100 lines of bash, I suggest just checking out the
         | source code. Very easy to understand once you know the basics
         | of containerization being basically just cgroups, namespaces,
         | and filesystem level isolation. I link it to people who are
         | trying to learn about what containerization actually does.
        
       | sbarre wrote:
       | Just a note that this repo's latest update was in 2015
        
         | tyingq wrote:
         | It's a short bash script calling out to things like btrfs,
         | cgcreate, cgexec, nsenter, etc. All of which get updates
         | regularly.
        
         | [deleted]
        
         | quocanh wrote:
         | You're telling me it's so stable and mature that it hasn't
         | needed an update in 7 years? Incredible.
        
           | andirk wrote:
           | It can mean that but the world is a wicked place and that
           | means no security updates either. Maybe none are needed.
        
       | robertlagrant wrote:
       | With all those prerequisites it's definitely possible. I can
       | implement Docker witt one prereq in one line of Bash:
       | docker "$@"
       | 
       | You're welcome, internet.
        
         | [deleted]
        
         | kuschku wrote:
         | Except, docker has the same prerequisites. That's kind of the
         | point of this excercise, to show that docker is primarily glue
         | between existing tools, not necessarily new technology.
        
           | vbezhenar wrote:
           | For me docker is three things:
           | 
           | 1. Dockerfile concept.
           | 
           | 2. Container image format (which is know known as OCI
           | container).
           | 
           | 3. Docker hub which is a repository of containers including
           | high-quality ones.
           | 
           | Every thing is essential and bringed innovation.
           | 
           | Launching container is boring and not really interesting
           | indeed.
        
       ___________________________________________________________________
       (page generated 2022-10-15 23:00 UTC)