Reputation: 3
I am just starting to learn about docker. Is docker repository (like Docker Hub) useful? I see the docker image as a package of source code and environment configurations (dockerfile) for deploying my application. Well if it's just a package, why can't I just share my source code with the dockerfile (via GitHub for example)? Then the user just downloads it all and uses docker build
and docker run
. And there is no need to push the docker image to the repository.
Upvotes: 0
Views: 481
Reputation: 159722
There are two good reasons to prefer pushing an image somewhere:
docker run
an image from a repository, without additional steps of checking it out or building it.Think of this like any other software: for most open-source things you can download its source from the Internet and compile it yourself, or you can apt-get install
or brew install
a built package using a package manager.
By the same analogy, many open-source things are distributed primarily as source code, and people who aren't the primary developer package and redistribute binaries. In this context, that's the same as adding a Dockerfile
to the root of your application's GitHub repository, but not publishing an image yourself. If you don't want to set up a Docker Hub account or CI automation to push built images, but still want to have your source code and instructions to build the image be public, that's a reasonable decision.
Upvotes: 1
Reputation: 5094
That is how it works. You need to put the configuration files in your code, i.e,
Dockerfile
and docker-compose.yml
.
Upvotes: 0