Moving existing docker image to Azure - azure

We have an existing docker container which is running an dotnet core website. Requirement is to move this container to Azure and run website over cloud.
All tutorials or Howtos point at creating new docker image.Can someone provide me a link or direction to achieve this requirement.

Just push the image to a docker repository that is accesible externally and pull the image from there. Depending on what you use (vms\webapp\container instances) procedures for pulling will be different. For vm's - regular procedure, for webapps - this for container instances - this

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,

How do you mount Azure files on a multi container web app?

B"H
I'd like to use Azure web apps to host staging servers for wordpress.
The best way to ensure that staging is as close as possible to live seems to be docker.
I use docker-compose on my dev machine and it works great. I would like to replicate that setup on azure.
My docker-compose.yml file sets up three containers 1) mysql 2) phpMyAdmin 3) my-wordpress-container
I mount three volumes
- ./data/mysql:/var/lib/mysql
- ./data/init/:/docker-entrypoint-initdb.d
in the db container and
- ./site/wp-content/uploads:/var/www/html/wp-content/uploads
in the wordpress container.
Most important is the /docker-entrypoint-initdb.d file for bootstrapping the db with test data.
How would I accomplish that in Azure web apps?
Before answering... Please do not explain how to deploy multiple containers on App services using docker-compose. Or post links to tutorials on hosting Wordpress in that environment. That is both simple and not quite enough for it to be useful.
Also, please do not post links about mounting File Shares in web apps. That is also quite simple.
The question is how to mount File Shares into a multi container setup. Specifically how I might be able to mount the /docker-entrypoint-initdb.d to bootstrap the db with test data.
This is totally doable in Container Instances. However there are other features that make it unusable for this solution.
I think this documentation is what you are looking for:
https://learn.microsoft.com/en-us/azure/app-service/containers/how-to-serve-content-from-azure-storage#use-custom-storage-in-docker-compose
From the docs:
Azure Storage can be mounted with multi-container apps using the custom-id. To view the custom-id name, run az webapp config storage-account list --name <app_name> --resource-group <resource_group>.
In your docker-compose.yml file, map the volumes option to custom-id. For example:
wordpress:
image: wordpress:latest
volumes:
- <custom-id>:<path_in_container>
There is a way to mount disks from Azure web apps, just google "mount disk from azure web app". There is a good blog post from TOM KERKHOVE.
However, I would advise you against this, currently the Azure Storage REST API appears more stable https://learn.microsoft.com/en-us/rest/api/storageservices/
Azure Web-Apps enables multi-containers in preview at the moment. Web-Apps does come with MySql as part of the instance. But not recommended for when you want to scale you Web-Application. So it is best to host the MySQL in MySQL as a service.
If you go to the link below it will walk you how to host Wordpress and Redis within Azure Web-App with multi-containers. Using My-SQL Service for the database and persistent storage.
https://learn.microsoft.com/en-gb/azure/app-service/containers/tutorial-multi-container-app
If you would still want to run MySQL in docker you may want to consider using Azure Kubernetes Service to host all the containers instead.
I hope this helps.

Setup Azure Pipelines for a Azure multi container app (multiple repositories)

I currently have a web app split into three parts. Each part has its own git repository.
Frontend Angular (foo.bar)
Backend Angular (foo.bar/admin)
.NET Core API (foo.bar/api)
In front sits an NGINX Server which acts as a reverse proxy. Currently, it all runs on a VM together with a Jenkins Server which allows me to develop and deploy each part separately, which I really like.
I would like to containerize the application and move it to Azure Web Service for Containers. For the CD/CI I would like to use Azure DevOps & Azure Pipelines. Since Azure Web Service for Containers supports multi-container via Docker Compose and Kubernetes.
The main question is:
How can I build and deploy one specific container (e.g. Azure/frontend:10) in the multi-container (via Docker Compose) environment? (Without building all the other containers)
If that is possible...
How do I set up the Azure Pipelines and Azure Container Registry to allow me separate container deployments
Where does the docker-compose file live? In a separate repository?
Where does the reverse proxy NGINX Dockerfile live? In a separate repository as well?
Or do I need to use Kubernetes?
Alternately I could use three different App Webs on the same Service Plan and control it per domain/sub-domain.
Frontend Angular (foo.bar)
Backend Angular (admin.foo.bar)
.NET Core API (api.foo.bar)
I don’t know where to start. It is a small project too. I don’t want to make it too complicated.
Any tip is more than welcome.
Thanks in advance!
I do not have experience with Azure Pipelines, but there are some ideas about Azure Container Registry and the Azure Web App for Container.
First, if you just want to build one specific container in the multi-container via Docker compose, you can just set this in the tutorial:
version: '3.3'
services:
db:
image: mysql:5.7
volumes:
- db_data:/var/lib/mysql
restart: always
environment:
MYSQL_ROOT_PASSWORD: somewordpress
MYSQL_DATABASE: wordpress
MYSQL_USER: wordpress
MYSQL_PASSWORD: wordpress
The compose also can be work with one container set in the file.
Second, the compose file can be everywhere that you run the command to create Web App for Container. For example, you can run the CLI command in your local machine with the compose file that store in your local machine.
Third, if you use Azure Web App for Container, you should prepare the docker image ready before in your repository, for example, the Azure Container Registry. It does not like docker compose installed in your local machine.
The AKS is also a good choice. You can create the service one by one or set them all in one yaml file. It's quite flexible.
Hope this will help you. If you need more help about the AKS or ACR please give the message.
You can use a container registry which will allow you to use docker to build each individual containers. You can then deploy a multi container app using containers from the container registry.
Building the container file follows the standard methods allowing you to copy configure and so forth. Once built you can push these by tagging them as follows: container_registry_name/container_name:{{.Run.ID}}
I would suggest based on the provided sample using a production database instead of a container as I have run into issues where a db data gets reset on container restart. Volumes for files can be persisted with the below:
${WEBAPP_STORAGE_HOME}/something/another:/var/www/html
Docker-Compose for containers does not (currently) allow you to use build in the azure pipeline as its meant for deployment only
One will need first build the dockerfiles and then reference your newly stored container registry images in docker-compose.yml. Also please take note that you cannot simply reference a docker hub image and a container registry image in the same compose file. You will need to pull and tag or build and tag the container to use it in that way. You can either use container registry images or public images.
In order to for your app to be able to connect to these images you need to add this to your app settings as well as allow admin in the container registry service:
DOCKER_REGISTRY_SERVER_USERNAME = [azure-container-registry-name]
DOCKER_REGISTRY_SERVER_URL = [azure-container-registry-name].azurecr.io
DOCKER_REGISTRY_SERVER_PASSWORD = [password]
Once you have your basic app setup you can then configure your continous integration options for further development such as webhooks, build options and so forth.

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.

What is container orchestration?

I have a GitLab repo, which uses docker container registry.
I want to push some of built containers to production using only one button click.
I heard that Kubernetes and Docker Swarm can help me, but I don't understand what it is
Can you explain in human language what is docker swarm and how can I use it to solve my task?
I want to push some of built containers to production using only one button click
You don't need docker orchestration for that, just docker.
More specifically, docker image push (previously docker push)
see "GitLab Using Docker Build"
Container orchestration is what is needed to transition from deploying containers individually on a single host, to deploying complex multi-container apps on many machines.
That is not what you are trying to do here: you just need to push images to a registry.

Resources