I'm looking to figure out how to build a Docker image as a file, copy it to my NAS (which is also running Docker), and then add that image from the file. I'm not a pro at this, so I might be missing something obvious. I've created a few apps that I'd like to run in Docker, and since they're just for my personal use, I'd prefer not to use DockerHub. Also, I'm using Visual Studio for this. Any guidance would be appreciated!
5 Answers
Instead of trying to move the built image, why not just transfer your Dockerfile directly to your NAS and build the image there? That might save you a lot of hassle. If you're set on moving an image, the commands `docker save` and `docker load` are what you want to look into.
I've been using GitHub's container registry, which is both private and free if you have a GitHub account. Just remember you’ll need to log in to Docker with your GitHub credentials. It works well for individual use!
While it's totally possible to build and run images locally without a registry, just remember that using a repository has its benefits. Check the Docker documentation for commands like `docker image save` and `docker image import` for more info!
Here's a thought for a more future-proof setup: You could deploy the linuxserver code-server image on your NAS, allowing you to run VS Code from your browser. Then, install Docker CLI in that container for building images directly on the NAS. It'll create a really flexible development environment that's accessible from anywhere.
You can save your Docker image as a tar file using `docker save`, then copy that file over to your other machine. If you're interested, you could also set up your own private Docker registry using Docker's official `registry` image. It’s pretty straightforward and allows you to build and push images easily, especially if you're working with different CPU architectures.
Hosting your own docker registry is a great idea! You can push and pull without authentication, making it perfect for local development. Just run `docker run -d -p 5000:5000 --restart always --name registry registry:2`, and you're good to go.
That’s cool! I prefer a self-hosted registry because it gives more visibility over the images I've pushed. The built-in registry in my self-hosted Gitea works well for me.