You can also login to DockerHub using a Secret in OpenShift to increase the pull rates limitations from 100 to 200 every 6 hours (this will mitigate the issue, but not solve it completely if you do not have a paid account on DockerHub):
oc create secret docker-registry docker-hub-secret --docker-server=docker.io --docker-username=your-dockerhub-username --docker-password=your-dockerhub-password --docker-email=your-dockerhub-email
Login to Container Registries 🔑
Login to GitHub Container Registry
Use your existing GitHub account if you have one:
- Create a Personal Access Token for GitHub packages at https://github.com/settings/tokens/new
- Provide a meaningful description for the token, and enable the following scopes when creating the token:
write:packages: publish container images to GitHub Container Registry
delete:packages: delete specified versions of private or public container images from GitHub Container Registry
- You might want to store this token in a safe place, as you will not be able to retrieve it later on github.com (you can still delete it, and create a new token easily if you lose your token)
- 👨💻 Log in to the GitHub Container Registry in your terminal (change
echo "ACCESS_TOKEN" | docker login ghcr.io -u USERNAME --password-stdin
On Windows use this command:
docker login ghcr.io -u USERNAME -p "ACCESS_TOKEN"
See the official GitHub documentation.
Login to quay.io
- Create an account at https://quay.io
- Login in your terminal (you will be asked for username and password)
docker login quay.io
Login to DockerHub
👩💻 Run in your terminal:
- Provide your DockerHub username and password.
Publish your image 📢
Once you built a Docker image, and you logged in to a Container Registry, you might want to publish the image to pull and re-use it easily later.
Publish to GitHub Container Registry
The GitHub Container Registry is still in beta but will be free for public images when fully released. It enables you to store your Docker images at the same place you keep your code! 📦
Publish to your user Container Registry on GitHub:
docker build -t ghcr.io/github-username/my-image:latest .
docker push ghcr.io/github-username/my-image:latest
For example, to the MaastrichtU-IDS organization Container Registry on GitHub:
docker build -t ghcr.io/maastrichtu-ids/jupyterlab:latest .
docker push ghcr.io/maastrichtu-ids/jupyterlab:latest
If the image does not exist, GitHub Container Registry will create it automatically and set it as Private by default. You can easily change it to Public in the image settings on github.com.
Publish to Quay.io
Quay.io is free for public images and does not restrict images pulls.
docker build -t ghcr.io/quay-username/my-image:latest .
docker push quay.io/quay-username/my-image:latest
Publish to DockerHub
If you are login with your DockerHub user on the DSRI, it should allow you to pull DockerHub images in your project (see above).
- Create the repository on DockerHub (attached to your user or an organization)
- Build and push the image:
docker build -t dockerhub-username/jupyterlab:latest .
docker push dockerhub-username/jupyterlab:latest
You can also change the name (aka. tag) of an existing image:
docker build -t my-jupyterlab .
docker tag my-jupyterlab ghcr.io/github-username/jupyterlab:latest
Use automated workflows
You can automate the building and publication of Docker images using GitHub Actions workflows 🔄
👀 Check the .github/workflows/publish-docker.yml file to see an example of a workflow to publish an image to the GitHub Container Registry.
👩💻 You only need to change the
IMAGE_NAME, and use it in your GitHub repository to publish a Docker image for your application automatically! It will build from a
Dockerfile at the root of the repository.
The workflow can be easily configured to:
- publish a new image to the
latesttag at each push to the main branch
- publish an image to a new tag if a release is pushed on GitHub (using the git tag)
v0.0.1published as image