Live data from Hacker News

Linux containers in 500 lines of code (2016)

blog.lizzie.io

1–10 of 31 posts

Re: Linux containers in 500 lines of code (2016)

#6
post #4
post #3

Docker in ~100 lines of bash: https://github.com/p8952/bocker

"100 lines of bash" is pretty generous. they might as well have just made it 1 line of bash with the way the code is written

Only the first few lines of the script look dense. Everything else looks normal to me.

Re: Linux containers in 500 lines of code (2016)

#7
post #4
post #3

Docker in ~100 lines of bash: https://github.com/p8952/bocker

"100 lines of bash" is pretty generous. they might as well have just made it 1 line of bash with the way the code is written

That's not fair considering the two longest lines are for logging into dockerhub and parsing input arguments.

Re: Linux containers in 500 lines of code (2016)

#8
post #6
post #4

Earlier quoted context omitted.

"100 lines of bash" is pretty generous. they might as well have just made it 1 line of bash with the way the code is written

Only the first few lines of the script look dense. Everything else looks normal to me.

Stuff like https://github.com/p8952/bocker/blob/master/bocker#L94 is super dense.

I might write that something like:

    cid="$(
      ps o ppid,pid |
        grep "^$(
          ps o pid,cmd |
            grep -E "^\ *[0-9]+ unshare.*$1" |
            awk '{print $1}'
        )" |
        awk '{print $2}'
    )"

Re: Linux containers in 500 lines of code (2016)

#9
post #8
post #6

Earlier quoted context omitted.

Only the first few lines of the script look dense. Everything else looks normal to me.

Stuff like https://github.com/p8952/bocker/blob/master/bocker#L94 is super dense. I might write that something like: cid="$( ps o ppid,pid | grep "^$( ps o pid,cmd | grep -E "^\ *[0-9]+ unshare.*$1" | awk '{print $1}' )" | awk '{print $2}' )"

or maybe even cid=$(pgrep -P $(pgrep -f "unshare.*$1")).

Re: Linux containers in 500 lines of code (2016)

#10
post #8
post #6

Earlier quoted context omitted.

Only the first few lines of the script look dense. Everything else looks normal to me.

Stuff like https://github.com/p8952/bocker/blob/master/bocker#L94 is super dense. I might write that something like: cid="$( ps o ppid,pid | grep "^$( ps o pid,cmd | grep -E "^\ *[0-9]+ unshare.*$1" | awk '{print $1}' )" | awk '{print $2}' )"

I agree with you that their code is fairly dense, yours is overly verbose.

Having said that, looking at their code, I don’t get the impression they’re optimizing for LOC. There is plenty of verbosity and opportunity to remove lines of code if they wanted.

Post reply on HN