We host our container images in a GitLab Docker registry and want to deploy the containers using Octopus Deploy. How do I connect an external feed to GitLab to deploy the images?
Yes, this is possible. I’ve created some instructions below that will work on self-hosting and GitLabs cloud.
My GitLab has a group called Octopus Samples and a project called OctoPetShop.
Example Docker Container Image
To help with this article I have built and pushed a Docker image to the GitLab registry in my project called octopetshopweb.
The image has a path and a name for the GitLab registry and that naming convention is used to search and reference the image in Octopus.
The path and name of the image is octopus_samples/octopetshop/octopetshopweb
- octopus_samples - GitLab group
- octopetshop - GitLab project
- octopetshop - image name
Creating GitLab access token
We need to create an access key in your GitLab account to access the repository from Octopus. Even if your project in Gitlab is public, you still need an access key to search the Gitlab Registry. The access key is still needed for public projects so that it can actually access the GitLab registry not our own private registry.
In Gitlab, got to profile > Edit Profile > Access Tokens
Give the token a name (not used in Octopus) and assign the read_registry permission.
And click create personal access token and save the token somewhere safe.
Connecting Octopus external feed
In Octopus go to Library > External feeds > ADD FEED
Next, fill in all the required parameters.
Feed Type: Docker Container Registry
Feed Name: Relevant to your project
Registry Path: Leave this blank
Username and Password
Feed Username: This can be anything we just need the access token
Feed Password: Use the GitLab personal access token we created earlier
Next, Click SAVE AND TEST.
To search for the image, you need to search for the exact container image path and name. In my case, this would be octopus_samples/octopetshop/octopetshopweb.
And that’s it. You can then use this feed to deploy containers images in Octopus Deploy.