It seems there had been a change and az container exec
only accepts executables.
So I had to turn the commands into a script challenge.sh
#!/bin/sh
rm -rf /tmp/certificates/*
certbot register --email $EMAIL --server $SERVERURL --eab-kid $EABKID --eab-hmac-key $EABHMACKEY --agree-tos -n
certbot certonly --nginx --email $EMAIL --server $SERVERURL -d $DOMAIN
cp -avr /etc/letsencrypt /tmp/certificates
cp /var/log/letsencrypt/letsencrypt.log /tmp/certificates/
add this script to Dockerfile
...
COPY challenge.sh /root/challenge.sh
RUN chmod u+x /root/challenge.sh
pass on all dynamic parameters as environment variables when creating the container group
az container create --name $containerGroupName -g $registry.resourceGroup `
--image $image `
--registry-login-server $registry.loginServer --registry-username $credentials.username --registry-password $credentials.passwords[0].value `
--ip-address public `
--azure-file-volume-account-name $storageAccountName `
--azure-file-volume-account-key $storageAccountKey `
--azure-file-volume-share-name $storageAccountShareName `
--azure-file-volume-mount-path "/tmp/certificates" `
--environment-variables DOMAIN=esb-dev.$dnsSuffix `
--secure-environment-variables EMAIL=$EmailAddress SERVERURL=$ServerUrl EABKID=$EABKID EABHMACKEY=$EABHMACKEY
and then only execute this script on the container instance:
az container exec -n $containerGroupName -g $containerGroup.resourceGroup --exec-command "/root/challenge.sh"