I have clone TheSpaghettiDetective (https://github.com/TheSpaghettiDetective/TheSpaghettiDetective) repository and then use the docker-compose.yml to build it and it works great on my local machine. Now I want to push it to Azure Container Instances in a multi-container group, but can't get it working.
I tried using this tutorial from Microsoft, but this project is a lot more complex.
The docker-compose file creates 4 containers that run, I couldn't figure out push them to Azure Container Registry with the tutorial, but was able to do so easily with the docker extension in VS Code.
Then when I tried deploy the images, I was able to get the docker context setup but the images wouldn't deploy. I think because they rely on the files I downloaded from github, to so I think I need to setup a file share in azure???
Where do I go from here? Is there no easy way to clone the repository into azure and use docker-compose up like I'm used to?
The problem that the images don't deploy is the docker-compose.yml file does not set the image option. It only set the build option to build the images. But when the images are pushed into the ACR. You don't need to build the images again, just need to pull the images with the image option. See the example in the link you found:
version: '3'
services:
azure-vote-back:
image: mcr.microsoft.com/oss/bitnami/redis:6.0.8
container_name: azure-vote-back
environment:
ALLOW_EMPTY_PASSWORD: "yes"
ports:
- "6379:6379"
azure-vote-front:
build: ./azure-vote
image: mcr.microsoft.com/azuredocs/azure-vote-front:v1
container_name: azure-vote-front
environment:
REDIS: azure-vote-back
ports:
- "8080:80"
You can find that the docker-compose.yml file configures the image to set the image name and use the build option to build the images. So try to add the image option in the docker-compose.yml file.
Related
I want to deploy a web application, which is built with Docker into a Azure web app.
There are a lot of tutorials and documentation about how to easily deploy a single docker image into Azure. But how to deploy multiple images into Azure?
I want to achieve this:
Local development with Docker-Compose. Works.
Versioning with GitHub. Works.
GitHub actions > Building the Docker images and pushing it to Docker-Hub (maybe not necessary, if the images are registered in Azure). Works.
Deploy everything to Azure and run the web application.
There is a similar question here: How to deploy a multi-container app to Azure with a Github action?
But I want to avoid the manual step, which is mentionend in the answer.
My docker-compose.yml:
version: '3.8'
services:
server-app:
image: tensorflow/serving
command:
- --model_config_file=/models/models.config
ports:
- 8501:8501
container_name: TF_serving
tty: true
volumes:
- type: bind
source: ./content
target: /models/
client-app:
build:
context: ./client-app
dockerfile: dockerfile
image: user1234/client-app:latest
restart: unless-stopped
ports:
- 7862:80
I am trying to cache images locally in a Docker registry using a pull through cache as described here: https://docs.docker.com/registry/recipes/mirror/. But when I do, Docker seems to ignore the pass-through cache and is instead pulling images directly from Docker Hub.
I have a Docker Compose file that I am using to run the registry:
version: '3.9'
services:
registry:
restart: always
image: registry:2
ports:
- 5000:5000
volumes:
- ~/.docker/registry:/var/lib/registry
- ./registry-config.yml:/etc/docker/registry/config.yml
And I have configured Docker to use the registry via the --registry-mirror option, which I have confirmed is taking effect by checking the output of docker info:
$ docker info
...
Registry Mirrors:
https://localhost:5000/
...
But when I try to pull an image, I see no activity in the registry's logs, as if Docker is ignoring the mirror option and just going straight to Docker Hub.
I have also confirmed the registry is working by pulling alpine:latest from Docker Hub, tagging it as localhost:5000/alpine:latest and pushing it to the registry, then pulling it back out again. Both of which work fine.
This is all being done on a Linux VM running Ubuntu.
Can someone please help me understand what I am doing wrong. and how I am supposed to get Docker to pull all images through the pull-through cache?
Thanks in advance for your help.
My simple docker-compose.yaml file:
version: '3'
services:
website:
image: php:7.4-cli
container_name: php72
volumes:
- .hi:/var/www/html
ports:
- 8000:80
in folder hi/ I have just an index.php with a hello world print in it. (Do I need to have a Dockerfile here also?)
Now I just want to run this container with docker compose up:
$ docker compose up
host path ("/Users/xy/project/TEST/hi") not allowed as volume source, you need to reference an Azure File Share defined in the 'volumes' section
What has "docker compose" up to do with Azure? - I don't want to use Azure File Share at this moment, and I never mentioned or configured anything with Azure. I logged out of azure with: $az logout but got still this strange error on my macbook.
I've encountered the same issue as you but in my case I was trying to use an init-mongo.js script for a MongoDB in an ACI. I assume you were working in an Azure context at some point, I can't speak on that logout issue but I can speak to volumes on Azure.
If you are trying to use volumes in Azure, at least in my experience, (regardless if you want to use file share or not) you'll need to reference an Azure file share and not your host path.
Learn more about Azure file share: Mount an Azure file share in Azure Container Instances
Also according to the Compose file docs:
The top-level volumes key defines a named volume and references it from each service’s volumes list. This replaces volumes_from in earlier versions of the Compose file format.
So the docker-compose file should look something like this
docker-compose.yml
version: '3'
services:
website:
image: php:7.4-cli
container_name: php72
volumes:
- hi:/var/www/html
ports:
- 8000:80
volumes:
hi:
driver: azure_file
driver_opts:
share_name: <name of share>
storage_account_name: <name of storage account>
Then just place the file/folder you wanted to use in the file share that is driving the volume beforehand. Again, I'm not sure why you are encountering that error if you've never used Azure but if you do end up using volumes with Azure this is the way to go.
Let me know if this helps!
I was testing to deploy docker compose on Azure and I faced the same problem as yours
then I tried to use docker images and that gave me the clue:
it says: image command not available in current context, try to use default
so I found the command "docker context use default"
and it worked!
so Azure somehow changed the docker context, and you need to change it back
https://docs.docker.com/engine/context/working-with-contexts/
I have a docker-compose.yml file which is created from a build step in Azure Devops. The build step works well and I can see how the docker-compose.yml file is produced. That makes sense to me.
However, it is looking for a normal docker image to run one of the services and the other service is one I've created and am hosting in my Azure Container Registry.
The docker compose file looks like this:
networks:
my-network:
external: true
name: my-network
services:
clamav:
image: mkodockx/docker-clamav#sha256:b90929eebf08b6c3c0e2104f3f6d558549612611f0be82c2c9b107f01c62a759
networks:
my-network: {}
ports:
- published: 3310
target: 3310
super-duper-service:
build:
context: .
dockerfile: super-duper-service/Dockerfile
image: xxxxxx.azurecr.io/superduperservice#sha256:ec3dd010ea02025c23b336dc7abeee17725a3b219e303d73768c2145de710432
networks:
my-network: {}
ports:
- published: 80
target: 80
- published: 443
target: 443
version: '3.4'
When I put this into an Azure App Service using the Docker Compose tab, I have to select an image tab - either Azure Container Registry or Docker Hub - I'm guessing the former because I am connected to that.
When I start the service, my logs say:
2020-12-04T14:11:38.175Z ERROR - Start multi-container app failed
2020-12-04T14:23:28.531Z INFO - Starting multi-container app..
2020-12-04T14:23:28.531Z ERROR - Exception in multi-container config parsing: Exception: System.NullReferenceException, Msg: Object reference not set to an instance of an object.
2020-12-04T14:23:28.532Z ERROR - Start multi-container app failed
2020-12-04T14:23:28.534Z INFO - Stopping site ingeniuus-antivirus because it failed during startup.
It's not very helpful, and I don't think there's anything wrong with that docker-compose.yml file.
If I try to deploy ONLY the service from the Azure Container registry, it deploys, but doesn't deploy the other service.
Does anyone know why the service doesn't start?
Well, there are two problems I find in your docker-compose file for the Azure Web App.
One problem is that Azure Web App only supports configuring one image repository in the docker-compose file. It means you only can configure the Docker Hub or ACR, not both.
Another problem is that Azure Web App does not support the build option in the docker-compose file. See the details here.
According to all the above, I suggest you can create all your custom images and push them to the ACR and use the ACR only.
I would like to configure continuous integration from VSTS to Azure Container Registry and then to WebApp.
Here's my docker-compose.yml file:
As you can see I'm using an Asp.Net core + mssql.
version: '3'
services:
api:
image: tbacr.azurecr.io/myservice/api
container_name: api
build:
context: ./Api
dockerfile: Dockerfile
ports:
- "8000:80"
depends_on:
- db
db:
image: "microsoft/mssql-server-linux"
container_name: mssql
environment:
SA_PASSWORD: "testtest3030!"
ACCEPT_EULA: "Y"
MSSQL_PID: "Developer"
ports:
- "127.0.0.1:8001:1433"
Here's my task from VSTS:
And I think the major task is Build Services and PublishServices
So, please take a look below:
Build Services
PublishServices
And finally, in Azure Container Registry I have:
So, the question is how can I deploy it to the WebApp. I have tried right-click to api: latest repository and deploy to WebApp but the endpoint does not respond
There is 2 steps im VSTS : build and release. It seems your build part is ok. So your docker image is pushed in your repo. Then you have to configure the build part in VSTS that will get the image you just pushed on the repo and deploy it on a server.
HTH