1

I pulled a standard docker ubuntu image and ran it like this:

docker run -i -t ubuntu bash -l

When I do an ls inside the container I see a proper filesystem and I can create files etc. How is this different from a VM? Also what are the limits of how big a file can I create on this container filesystem? Also is there a way I can create a file inside the container filesystem that persists in the host filesystem after the container is stopped or killed?

user2399453
  • 2,930
  • 5
  • 33
  • 60
  • Take a look at this question https://stackoverflow.com/questions/16047306/how-is-docker-different-from-a-normal-virtual-machine for how Docker works. To share a file with the host you can use volumes with `-v host_path:container_path` – Julian Jun 17 '17 at 22:57

1 Answers1

1

How is this different from a VM?

A VM will lock and allocate resources (disk, CPU, memory) for its full stack, even if it does nothing.

A Container isolates resources from the host (disk, CPU, memory), but won't actually use them unless it does something. You can launch many containers, if they are doing nothing, they won't use memory, CPU or disk.
Regarding the disk, those containers (launched from the same image) share the same filesystem, and through a COW (copy on Write) mechanism and UnionFS, will add a layer when you are writing in the container.
That layer will be lost when the container exits and is removed.

To persists data written in a container, see "Manage data in a container"

For more, read the insightful article from Jessie Frazelle "Setting the Record Straight: containers vs. Zones vs. Jails vs. VMs"

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250