Hey everyone! I've been diving into Docker lately, and I'm almost there with my understanding, but I'm still a bit confused about one thing. What do we mean when we talk about an 'empty' Docker container? Specifically, I'm referring to a container created using a Dockerfile that looks like this:
FROM scratch
How does that differ from a typical container, like one that starts from something like Ubuntu? What's actually in an empty container and what is it made up of? Any insights would be super helpful!
4 Answers
So here's the thing: a regular Ubuntu container comes with a bunch of basic Linux tools and a package manager, so you have a working environment right out of the box. An 'empty' container, though? You’ve got to build up everything from scratch—literally! It doesn't provide even a minimal Unix environment; you start with nothing.
I recommend saving it as a tarball and examining the contents. That’ll give you a clear picture of what an empty container really is!
To put it simply, scratch means nothing; there’s no actual image to pull or run. It's a keyword now in Docker for indicating that you’re starting from a blank slate. So, if you want a real container, you might start from something like Ubuntu instead.
When you're referencing 'scratch', you're basically talking about an empty image. Scratch is literally zero bytes—it's just a blank filesystem. It’s useful for creating minimal containers, especially if you’re using statically linked binaries, like Go binaries, which run just fine in that empty space. You can even treat it like a zip file: add whatever files you need to it and voila, you've got yourself a Docker image. This comes in handy for packing databases or other data files to be used in test environments!
Related Questions
How To Get Your Domain Unblocked From Facebook
How To Find A String In a Directory of Files Using Linux