Build & Push to custom registry
In this guide, we will look at how to push an image to a selfhosted docker registry
Requirements:
- a selfhosted docker registry, example: (cfr-r.divsphere.net)
- docker
- custom project with a dockerfile that you want to build and push
Building a project
To build your project, you’ll need to run the following command:
Docker Build Command
sudo docker build -t cfr-r.divsphere.net/myapp:latest -f Dockerfile .
-t:
specifies the tag of the image you need to put it in this format [location]/[yourapp]:[version]
(the location needs to be added here because otherwise it'll try to push to the dockerhub)
-f:
specifies the location of the dockerfile
the .
at the end specifies the context it’ll will run in.
Pushing a project
Next you can push it to the registry like this:
Docker Push Command
sudo docker push cfr-r.divsphere.net/myapp:latest
After the push you'll need to specify the image that you want to push. For windows you dont have to add the sudo