I'm trying to push images to an instance of Azure Container Registry but it keeps failing even though I have logged in successfully.
The tag needs to be:
azure_registry_name.azurecr.io/container-name:tag
in my case:
docker push sunlabregistry.azurecr.io/python
Building on the response from Batman. In my case, I needed to follow the steps described here:
In particular, the name of the container cannot be any name we want. It needs to match the name of the repository which we have indicated when we created the "Scope map" in our container registry. To make it more concrete, let's list all the steps from creating the container registry up to doing "docker push":
Create a "Container Registry", and copy the "Login server", which in the example given by Batman is
sunlabregistry.azurecr.io
, but I use the namemy_registry.azurecr.io
In this Container Registry, create a "Token".
When creating the Token, we have a field called "Scope map". Click on "Create new"
We will get a window where we have text fields "Repository" and "Permissions". We can indicate any name we want in the text field "Repository". Let this name be
my_repository
. In the permissions, I selected all, which includes content/read, content/write.Once the Scope map has been created, we can finally generate our "Token". In the token details, select password1 or password2, and select the Generate icon.
After generating a password, copy and save it to a safe location. Azure let's you copy the full docker login command with the password included, something like:
docker login -u MyToken -p my_password my_registry.azurecr.io
Do docker login with the above command (maybe adding "sudo" at the beginning)
Tag your image as follows:
sudo docker image tag <container_id> my_registry.azurecr.io/my_repository:my_version
where
my_version
can be anything we want, butmy_repository
needs to match what we entered when creating the Token, in step 4 above.Push the tagged image as follows:
sudo docker push my_registry.azurecr.io/my_repository:my_version
First you have tag your local images with sunlabregistry.azurecr.io/python-app:v1 then use docker push /python-app:v1 tag should be mentioned.
In my case I faced the error when I tried to publish from visual studio ide to the Azure container registery. Reason the user didn't had AcrPush role, after assigning the role I was able to publish. This can be done through portal as well as CLI. Hope this helps some one
Through portal -
In your ACR's blade (left-hand menu), click on "Access Control (IAM)". Click on "+ Add" > "Add role assignment". The "Add role assignment" pane will open on the right.
In the "Role" dropdown, select AcrPush to allow the user to push images to the registry. If the user also needs to pull images, you might consider assigning AcrPushPull role instead.
© 2022 - 2024 — McMap. All rights reserved.
docker tag container-name sunlabregistry.azurecr.io/container-name:tag
anddocker push acidemomvp.azurecr.io/aci-tutorial-app:v1
The rest is all explained in my step-by-step tutorial. – Mccollough