Deploy docker to on-premise using azure CI-CD - docker

I have created.NetCore Application and was successfully deployed to the local PC docker container.
Now I am trying to build it from Azure DevOps and publish it to one of my servers hosted on-premise.
Now I have no idea how to host it. Also not sure what is Docker Registry Service Connection & Container Registry Type.
My DevOps server is also hosted on-premise with no docker installed on it.
I have a docker account with one private repository.
Please suggest how to continue as I am getting the below error while building the image
open //./pipe/docker_engine: The system cannot find the file specified. In the default daemon configuration on Windows, the docker client must be run elevated to connect. This error may also indicate that the docker daemon is not running.
Thanks

Deploy docker to on-premise using azure CI-CD
If you want to deploy app to the local PC docker container, you can use Self-hosted Agent(Build Pipeline and Release Pipeline) or Deployment Group(Release Pipeline).
Note: we need set the self-agent on the server where have docker installed.
Then you could try the following pipeline settings.
Here is a blog about ASP.Net Application Deployment in Docker for Windows.
You could use Command Line Task to run the docker command. In this case, you can move the local build and deploy process to azure devops

Related

Cannot run program "docker": error=2, No such file or directory in jenkins

I installed Jenkins on AWS and installed dockerhub on my local machine. When i created a pipeline job in Jenkins and build then I got an error in last build stage.
https://github.com/Raahatx8/docker
I used above repo to create my pipeline, it includes dockefile and jenkinsfile.
This is the error
Your remote machine i.e. AWS doesn't have connection to the Docker daemon (which is in the local machine) to run the docker commands.
In order to achieve the same i.e. to run the docker commands, you need to do two things:
Enable Docker Remote API (in your local machine where docker is installed)
Download docker client (in AWS machine)
Refer to guide: https://gist.github.com/kekru/4e6d49b4290a4eebc7b597c07eaf61f2
Note: Make sure you need to open connection to particular port in local machine, so that AWS machine can connect.

Unable to create the docker network inside of App Service in Azure Release Pipeline

I'm trying to setup multi container application in Azure DevOps services. I have used "Azure Web App for Containers" task to run the application on App service with the support of docker compose. I have used "Run Services" part of Docker Compose Task and provided the docker-compose.yml file path.
When the deployment starts, the docker compose tries to create the docker network by adding alias in the prefix. I'm getting the parameter is incorrect. How to fix it?
Log is not retrieving in App Service Console
If I did not guess wrong, you are using Hosted Windows agent?
Because this error message HNS failed with error : The parameter is incorrect. represents a known NAT network created limitation on Windows.
Solution:
Just change the agent used to Ubuntu, and it will run successfully.
You can see, it's Succeed with Ubuntu agent:
BUT Failed with VS2017 Hosted agent:

Set Docker daemon options on Azure hosted agent

I'm messing around with Artifactory and have used the artififactory-pro docker container to get me up and running on an azure vm. I'm now trying to push a docker image to the docker-local repository within Artifactory. This is working locally but I had to change my local docker options to include the insecure-registry I set up.
To continue my POC further I want to be able to push to the artifactory docker repo using the MS hosted 'ubuntu-latest' agent with Azure pipelines but I believe I need to set the docker options on the agent to again allow the insecure regsitry as it's currently throwing the error:
[Error] Docker login failed for: http:/, http:.
How do I set the docker options on the MS hosted agent within my pipeline? I'm having to install .net-core 3.1 sdk during the pipeline so i'd like to think it is possible.
Thanks
As far as I know, you cannot set docker options to allow insecure regsitry on MS hosted agent. To set insecure registry, you have to modify some docker config file. But we are restricted to modify the system files of MS hosted agent for security reason, you will get access denied error if you try to do so.
The workaround is to create your own self-hosted agent on your local machine. So that you can set the insecure registry for docker daemon on local machine.
However you can also submit a feature request(click suggest a feature and choose azure devops) to Microsoft Development team. Hope they will consider implementing a feature to enable seting docker options on MS hosted agent.

Pull and push docker images without installed Docker

We need to transfer large number of docker images from Azure DevOps to private container registry (this registry does not have access to the Internet). For this matter there is proxy machine with Windows Server with Azure Cli and access to the Azure DevOps, but we are restricted with installing Docker there.
Is there a way to pull docker images from Azure DevOps and push them into another container registry without installed Docker? Perhaps there is slim version of Docker or some official script.
You can basically save it as an archive, and reload it the same way.

How to build docker images on AWS EC2 Windows Server instance?

We use Team City to build C# applications on a Windows server in AWS EC2.
Now there is a requirement to build Docker containers using the same system. The build steps have been tested locally and are able to produce a docker image.
Docker is not installing correctly on the server which leads to the builds failing.
Docker Edge supports Windows Server but fails on EC2 due to Hyper-V not functioning correctly.
Docker Toolbox also fails because VT-X/AMD-v are not enabled.
Is there any way to build docker images on an AWS EC2 Windows Server instance?

Resources