The most common way to host Docker images is via DockerHub. DockerHub is maintained by Docker, so when logged into Docker CLI (docker login) with a DockerHub account, it is possible to commit and push images.
However, more commonly, "automated builds" are utilized as they can connect to Git repositories (such as Github and Bitbucket) and will build images when triggered by a webhook after a commit has been pushed.
Using automated builds with Dockerfiles allows for easier tracking of changes as commiting an image directly will only show the layer history, versus a Dockerfile change history which can be easily read.
A simple and common method is to connect to Github, which will be the process outlined in the following steps:
- In DockerHub click
Create, then selectCreate Automated Build - Select
Create Auto-Build - Github, then navigate to, and select, the repository where the Dockerfile is maintained - Create the Automated Build by ensuring the fields are populated for
NameandShort Description, and clickCreate Build - The build has been created, now navigate to the
Build Settingstab - Under
Build Settingsdifferent builds can be added by supplying theirName,Dockerfile LocationandTag - Once a build is created, the build can be
Triggeredby clicking the button (Note: you must save any build settings before tiggering a build) - Under the
Build Detailstab, the current build(s) can be monitored. This currently is not automated in the UI, so the page must be refreshed to see active changes in build status
As highlighted in earlier sections, once the build is complete, the image can be pull'd via docker pull <repo>/<image>:<tag>.
Additionally, on run, if an image does not exist locally it will be pull'd automatically.