I'm aware that the typical way to start a Docker container is by importing the image first. The issue I have is that this process creates two large files on my system, taking up valuable disk space. On a multi-user system, this also makes my custom Docker image accessible to others, which I'd rather avoid. I was under the impression that there might be a way to run a container directly like this: `docker run custom-container.tar.bz`, without needing to import it first. Did I imagine this, or is there a method I'm missing?
3 Answers
It sounds like you might want to run your image from a secure location without exposing it. Unfortunately, Docker stores all images in its global store, which requires permission to access. So you can't avoid importing it altogether if you want Docker to manage it.
It sounds like there’s some confusion about how Docker works. When you run a container, it needs to use an image stored locally, meaning you have to import it first even if it’s just a file on your system. There’s no way to run it directly without that step since Docker relies on the image layers stored in its local database.
You could be thinking about using `docker load` which imports an image from a tar file, but either way, the image needs to be registered in Docker's local storage. If disk space is your concern, optimizing your images might help; consider using smaller base images like Alpine.
Exactly, you don’t really need to keep the tar file after loading it. I usually delete mine to save space.
Totally agree! Plus, if you're worried about space, Docker keeps only the necessary layers after running, so the container doesn't add that much overhead.