How to push a Docker image to an Azure Container Registry

Make sure you have the Azure CLI installed first, then:

# Log into your Azure account
az login

# Then into your container registry
az acr login --name <your-registry-name>

# Create an image alias
docker tag <image-name> <your-registry-name>.azurecr.io/<path/to/dir>

# Push the image
docker push <your-registry-name>.azurecr.io/<path/to/dir>

How to deploy a Docker image from an Azure Container Registry to a Container Instance

First, make sure your container registry has an admin account enabled – you’ll need it when deploying the image. You can do this either from the Azure Portal: [Container registry]/Access Keys/Admin user -> Enabled, or by running the command below:

az acr update -n <your-registry-name> --admin-enabled true

Once you’ve enabled the admin account, you can run the following command:

az container create --resource-group <your-resource-group> \
--name <your-container-name> \
--image <your-registry-name>.azurecr.io/<path/to/dir> \
--ip-address Public 
--ports <your-port>

Note that once created, you won’t be able to update all properties. To change some of the properties, you’ll need to first delete then redeploy the image.

– via Microsoft Docs

Running a Docker image and accessing the service it’s running


# Docker
docker run -p <local_port>:<docker_image_port> <docker_image_name>

# CURL
curl -X POST http://localhost:<local_port>

Find running images and their names

docker ps

Editing files in a Docker image (e.g. an Azure ML Model running on Azure Container Instances)


docker exec -it <name> /bin/bash
    ls
    pip freeze

    cd /var/azureml-app

    ls
    python score.py
    cat score.py    

    apt-get update
    apt-get install nano
    nano score.py

    cat score.py

    exit


docker exec -it <name> /bin/bash
    check score.py

docker restart <name>

> Call updated service

Passing environment variables to Docker images

Create an .env file, and pass it to the Docker image. Works for Azure App Service application settings, too.

 docker run --env-file ./env.list
# env.list

YOUR_KEY=<your_value>
e.g.
APPINSIGHTS_INSTRUMENTATIONKEY=<that_guid>
WEBSITES_ENABLE_APP_SERVICE_STORAGE=false
WEBSITES_PORT=8080
...

– via Stack Overflow