Fine grained permissions for docker registry - azure

I want to setup a private docker registry and need to be able to specify fine grained permissions on repository level e.g. I have repositories
foo
bar
baz
Developer A can see and pull from all three repositories but cannot push to any of them.
Developer B can push and pull to/from foo but cannot see any of the other repositories.
Developer C can push/pull from baz and pull from bar but cannot see foo.
As most of our services are in Azure I would prefer to use Azure Container Registry but it seems I can only assign permissions across the whole docker registry and not for individual repositories.
Is there a way to achieve what I want with Azure Container Registry and if not what are my alternatives (preferably open source)?

Just as you know, Azure Container Registry does not have the feature that you need, it just can control the access of all the repositories, not individual. So you cannot achieve your purpose in ACR.
Maybe you can try to create your own private docker registry in the VM, then you can follow the steps in Authentication and authorization in DTR. It seems you can control the access for the individual repository via the teams in docker registry. Hope it helps.

Related

How to get Docker Images from Azure container registry and run onpremise servers using docker-compose?

I am using azure devops for CI/CD pipelines and one thing I couldn't find out, getting images from Azure container registry and run those images inside of my onpremise debian server. (I build and pushed the images to ACR already).
On release pipeline section:
I set Azure Container repository as source type and selected the latest artifact from there
then created a dev stage
Added a Command line tool to execute some scripts on server
-->This is the step where I lost<-- I need somehow to get these image from repository and fire compose up command in the server.
Extra info: you cannot use your docker-compose.yml(which mine is inside of the azure repo in same project) because you are using ACR as source type, not the build itself or source code.
*in my humble opinion this is a good case to enrich a content. Because there is lack of docs and videos on internet.
thanks,

Naming policies for Azure Container Registries (ACR) artefacts

We (mostly) push docker images (containing maven builds) with semantic version tags to our Azure Container Registry (ACR), e.g. my-cool-app:1.0.0-SNAPSHOT. As in the maven-world suggested, a SNAPSHOT is a work in progress built, which may or may not gets overwritten any time ...
I am thinking of a dedicated ACR, which is used for production environment only. This ACR shall contain only released images, meaning no SNAPSHOT shall be contained in the image tag. I couldn't find any useful information if there is some sort tag naming policy, basically denying any kind of deploys containing SNAPSHOT, besides locking the images. Is there no way to define such rules on the ACR, or do we have to check that "programmatically" within the build/release pipeline?
There is not any document with naming policy before pushing the images to container registry but for workaround you can use of Content trust in Azure Container Registry
Azure Container Registry implements Docker's content trust model,
enabling pushing and pulling of signed images. This article gets you
started enabling content trust in your container registries.
As an image publisher, content trust allows you to sign the images you push to your registry. Consumers of your images (people or systems pulling images from your registry) can configure their clients to pull only signed images. When an image consumer pulls a signed image, their Docker client verifies the integrity of the image. In this model, consumers are assured that the signed images in your registry were indeed published by you, and that they've not been modified since being published.
This Content Trust will help to deny to push the images in Container registery as they might be not signed images to use as on production environment or in Azure Contaier Registry
For more information how to assign AcrImageSigner Role in the Container Registry You can refer this Mircosoft Document

Azure Container Registry as a general purpose repository?

Can we use Azure Container registry as a general purpose artifactory repository like VSTS Package Manager or Artifactory? If so, what are the common gotchas/pitfalls of doing so? Why is it (not) advisable?
Azure Container Register is a managed Docker registry service based on
the open-source Docker Registry 2.0. Create and maintain Azure
container registries to store and manage your private Docker container
images.
It seems that Azure Container Register cannot be used as a general purpose Artifactory repository. You can get more details from the document here.
ACR is focused on containers. That said, we are adding Helm Repository Support, which itself are just blobs. While we're not ready to take on generic artifacts as a first class experience, you can push images that derive FROM scratch.
Steve

Restrict access to gitlab container registry

I want to be able to let the users push a docker file along with code to gitlab and let the gitlab build the image, that can then be pulled by authenticated user of the project.
The problem is , I want to make sure the users dont push docker images directly to gitlab container registry , so that we can review the docker-files and control , and make sure the Dockefiles are using the Redhat only registry to pull stuff from.
How can we prevent users from pushing thier own built image to gitlab?
In other words , how can we make sure that docker image in the container registry of gitlab project is the one built by gitlab from dockerfile and is not the one pushed by the project users direclty from somewhere else?
deploy tokens is probably the best way forward. You can grant these on a per-repository or a group basis and specify granular access such as, for your use case read_registry as well as an optional expiry date.
Another option is to use personal access tokens. These are set globally for a user and you can specify as many as you like (eg one for each client), set an expiry date, and restrict access to read_registry.
I don't think it's currently possible. If you check gitlab's permissions model, you'll see that the user access levels determine what you can do in the container registry:
read rights are available as Reporter+
update rights are available as Developer+
If your users are developers, then they will be able to push images to the registry. If you want to limit that to gitlab-ci builds, you'd need to use protected branches and limit your users to Reporter access level (probably not what you want).
An alternative a bit convoluted would be to setup a second project that is used as the source for images, and configure its build setup to pull from the first project protected branch. Commits to the protected branch in the first project would always have to be reviewed and docker images would be pulled from the second project.

Run docker container on azure

I have a simple docker container which runs just fine on my local machine. I was hoping to find an easy checklist how I could publish and run my docker container on Azure, but couldn't find one. I only found https://docs.docker.com/docker-for-azure/, but this document kind of leaves me alone when it comes to actually copy my local docker container to Azure. Isn't that supposed to be very easy? Can anybody point me in the right direction how to do this?
But it is really easy.. once you know where to find the docs :-). I would take the azure docs as a starting point as there are multiple options when it comes to hosting containers in Azure:
If you're looking for this...
Simplify the deployment, management, and operations of Kubernetes -> Azure Container Service (AKS)
Easily run containers on Azure with a single command -> Container Instances
Store and manage container images across all types of Azure deployments
-> Container Registry
Develop microservices and orchestrate containers on Windows or Linux
-> Service Fabric
Deploy web applications on Linux using containers
-> App Service
Based on your info I would suggest storing the image using the Azure Container Registry and host the container using Azure Container Instances. No need for a VM to manage this way.
There is an excellent tutorial you could follow (I skipped the first 1 step since it involves creating a docker image, you already have one)
Another complete guide of pushing your image to azure and create a running container can be found here.
The good thing about Azure Container Instances is that you only pay for what you actually use. The Azure Container Registry is a private image repository hosted in Azure, if course you could also use Docker Hub but using ACR makes it all really simple.
In order to run an image, you simply need to configure a new VM with the Docker Daemon. I personally found Azure's documentation to be pretty complex. Assuming you are not trying to scale your service across instances, I would recommend using docker-machine rather than the Azure guide.
docker-machine is a CLI tool published by the Docker team which automatically installs the Docker Daemon (and all the dependencies) on a host. So all you would need to do is input your Azure subscription and it will automatically create a VM configured appropriately.
In terms of publishing the image, Azure is probably not the right solution. I would recommend one of two things:
Use Docker Hub, which serves as a free hosted Docker image repository. You can simply push images to Docker Hub (or even have them built directly from your Git repository).
Configure a CD tool, such as TravisCI or CircleCI, and use these to build your image and push directly to your deployment.
To run your docker image inside ACI, You can use of Azure Container Registry.
Step0: Create Azure Container Registry
Step1: Include a Dockerfile in your application code
Step2: Build the code along with the Dockerfile with a tag and create a
Docker image ( docker build -t imagename:tag .)
Step3: Push the Docker image to Azure container Registry with a image name and tag.
Step4: Now create a ACI, while creating, choose the image type as private, provide the image name, tag, image registry login server, image registry username, image registry password ( these details can be found under access keys tab inside Azure Container Registry)
Step5: choose running os as linux, in network step you can give an dns name for your ACI, then click on review & create
Step6: once ACI gets created you can go to overview and you can see fqdn, using fqdn you can access your application running inside Azure Container Instance.

Resources