3 ms·
> Docker is meant to be stateless. Containers have no permanent disk storage, whatever happens is ephemeral and is gone when the container stops. It's interest
by stevebmark 5y ago
> Docker is meant to be stateless. Containers have no permanent disk storage, whatever happens is ephemeral and is gone when the container stops.
It's interesting that this misconception made it into a clearly knowledgeable article. Containers have state on the writeable layer that is persisted between container stops and starts.
- plainnoodles 5y agoBut I think most people and tools consider "containers" to be volatile storage, like RAM. Non-volatile storage would be volumes. Honestly I think there is a lot to be said for making the writable layer of a container read-only. It makes sure that things like logging, if you care about them, go somewhere safe, or if you don't, get turned off explicitly. And also prevents gotchas like "oops wrote important data to /var/lib/notavolume when I meant to write to /var/lib/therightvolume" that show up at the worst times.
- beermonster 5y agoI’m not sure it’s a misconception. That’s how they’re intended to be used. Cattle not pets. If you don’t get used to not treating them as throw away you can end up accidentally relying on some state. As you say, the top layer is read/write but that doesn’t mean you should be relying on what you write there. Quite the opposite - that state should be somewhere else unless you can afford to lose it. I usually start mine with —-rm so they’re removed on shutdown. I’ve seen people apply security updates via ‘apt update; apt upgrade’ within a running container. Guess what happens when that container is eventually destroyed?