Live data from Hacker News

Build a Container Image from Scratch

danishpraka.sh

21–30 of 60 posts

Re: Build a Container Image from Scratch

#21

Earlier quoted context omitted.

Yeah, this. Docker/container's greatest feature is less the sandboxing than the distribution. The sandboxing is essential to making the distribution work well, but it's a side feature most of the time

It’s kind of funny that people think of “sandboxing” as the main feature of containers, or even as a feature at all. The distribution benefits have always been the entire point of Docker. The logo of Docker is a ship with a bunch of shipping containers on it (the original logo was clearer, but the current logo still shows this). “Containers” has never been about “containment”, but about modularity and portability.

Docker introduced an ambiguity in the meaning of the word "container". The word existed before Docker, and it was about sandboxing. Docker introduced the analogy of the shipping container, which as ranger207 says, is about sandboxing at the service of distribution.

The two meanings - sandboxing and distribution - have coexisted ever since, sometimes causing misunderstandings and frustration.

Re: Build a Container Image from Scratch

#22
post #6

Earlier quoted context omitted.

$_ is the last argument. Here's a better example to illustrate > echo 'Hello' 'world' 'my' 'name' 'is' 'godelski' Hello world my name is godelski > echo $_ godelski > !:0 !:1 !:2 "I'm" "$_" Hello world I'm godelski The reference manual is here[0] and here's a more helpful list[1] One of my favorites is > git diff some/file/ugh/hierarchy.cpp > git add $_ ## Alternatively, but this is more cumbersome (but more flexible…

If you want to add in another bash trick called Parameter Expansion[0] you can parse out the filename automatically with the special variable $_. Something like: > wget https://dl-cdn.alpinelinux.org/alpine/v3.18/releases/x86_64/alpine-minirootfs-3.18.4-x86_64.tar.gz && tar xzf ${_##*/} [0] https://www.gnu.org/software/bash/manual/html_node/Shell-Par...

##*/ is probably one of my most used parameter expansions. This was definitely a better solution than the one I proposed lol

Re: Build a Container Image from Scratch

#23
post #6
post #4

Earlier quoted context omitted.

I learned about $_ echo abc && echo $_ abc abc except it's used with wget... wget URL && tar -xvf $_ does this work? Shouldn't tar take a filename? hmm... also, it says there is an alpine layer with "FROM scratch"??

$_ is the last argument. Here's a better example to illustrate > echo 'Hello' 'world' 'my' 'name' 'is' 'godelski' Hello world my name is godelski > echo $_ godelski > !:0 !:1 !:2 "I'm" "$_" Hello world I'm godelski The reference manual is here[0] and here's a more helpful list[1] One of my favorites is > git diff some/file/ugh/hierarchy.cpp > git add $_ ## Alternatively, but this is more cumbersome (but more flexible…

[deleted]

Re: Build a Container Image from Scratch

#24
post #6
post #4

Earlier quoted context omitted.

I learned about $_ echo abc && echo $_ abc abc except it's used with wget... wget URL && tar -xvf $_ does this work? Shouldn't tar take a filename? hmm... also, it says there is an alpine layer with "FROM scratch"??

$_ is the last argument. Here's a better example to illustrate > echo 'Hello' 'world' 'my' 'name' 'is' 'godelski' Hello world my name is godelski > echo $_ godelski > !:0 !:1 !:2 "I'm" "$_" Hello world I'm godelski The reference manual is here[0] and here's a more helpful list[1] One of my favorites is > git diff some/file/ugh/hierarchy.cpp > git add $_ ## Alternatively, but this is more cumbersome (but more flexible…

  !!:s^diff^add
This is enough:

  ^diff^add

Re: Build a Container Image from Scratch

#25
post #6
post #4

Earlier quoted context omitted.

I learned about $_ echo abc && echo $_ abc abc except it's used with wget... wget URL && tar -xvf $_ does this work? Shouldn't tar take a filename? hmm... also, it says there is an alpine layer with "FROM scratch"??

$_ is the last argument. Here's a better example to illustrate > echo 'Hello' 'world' 'my' 'name' 'is' 'godelski' Hello world my name is godelski > echo $_ godelski > !:0 !:1 !:2 "I'm" "$_" Hello world I'm godelski The reference manual is here[0] and here's a more helpful list[1] One of my favorites is > git diff some/file/ugh/hierarchy.cpp > git add $_ ## Alternatively, but this is more cumbersome (but more flexible…

TIL! I use alt-. for that when running interactively, good to know there's a way to do that in a script

Re: Build a Container Image from Scratch

#27

Earlier quoted context omitted.

If you want to add in another bash trick called Parameter Expansion[0] you can parse out the filename automatically with the special variable $_. Something like: > wget https://dl-cdn.alpinelinux.org/alpine/v3.18/releases/x86_64/alpine-minirootfs-3.18.4-x86_64.tar.gz && tar xzf ${_##*/} [0] https://www.gnu.org/software/bash/manual/html_node/Shell-Par...

I want to make a small note, in that `$_` is a special Bashism (though it is supported widely), but Parameter Expansion is POSIX-standard and will work on all POSIX-compliant shells, not just Bash. https://pubs.opengroup.org/onlinepubs/009604499/utilities/xc...

You know I just realized after all these years I still don't quite know what a shell is.

You have iTerm, Terminal, etc. But what do those do? Those are not the shells themselves right?

Re: Build a Container Image from Scratch

#28

Earlier quoted context omitted.

I want to make a small note, in that `$_` is a special Bashism (though it is supported widely), but Parameter Expansion is POSIX-standard and will work on all POSIX-compliant shells, not just Bash. https://pubs.opengroup.org/onlinepubs/009604499/utilities/xc...

You know I just realized after all these years I still don't quite know what a shell is. You have iTerm, Terminal, etc. But what do those do? Those are not the shells themselves right?

iTerm and Terminal are pieces of software emulate a physical terminal environment. They take the output of programs/shells output characters and control codes to render text, clear the screen, etc.

The terminal emulator receives keyboard input via your operating system, and passes it to the shell program via stdin.

The shell is responsible for prompting you and handling whatever you type. For example the “$ “ waits for next character from the terminal emulator until you hit newline.

The shell is responsible for parsing your input, executing any child programs “ls” for example, outputting their content to stdout, and prompting you again.

Re: Build a Container Image from Scratch

#29

Earlier quoted context omitted.

Because Docker/OCI/etc got the most important part right (or at least much better than the alternatives): distribution. All you need to start running a Docker container is a location and tag (or hash). To update, all you do is bump the tag (or hash). If a little more complicated setup is necessary (environment variables, volumes, ports, etc) - this can all be easily represented in common formats like Docker compose o…

Sorry. I agree, but that's a different question. I'll circle back to that then. Why don't technical people make these interfaces, giving the same love to user experience that something like Docker gets. As you said, it is scriptable, and I think -- us all being programmers here -- we all know that means you can just make the interface easier.

Are you implying that docker or podman hasn't been made by _technical people_?

Re: Build a Container Image from Scratch

#30
post #2

Is there a windows version ?

Running the container on Windows is probably a lot more complicated because there’s no obvious built in chroot + mount filesystem command (at least from memory).

I believe they’re built on silos. I believe containerd itself is probably as low in the container runtime as you’d want to go… See https://github.com/microsoft/hcsshim for the actual bindings.

Post reply on HN