I have a working azure pipeline, something like this:
trigger: none
jobs:
- job: RunTest
workspace:
clean: all
pool:
vmImage: 'ubuntu-latest'
steps:
- task: Docker@2
displayName: Login to ACR
inputs:
command: login
containerRegistry: my-acr
- script: |
docker run my-registry.azurecr.io/somerepo/rnd-hello:latest
How to run now multiple shell scripts on the docker image?
For example, how to do the following now :
- cmake -DCMAKE_BUILD_TYPE=Release -Bbuild;
- cmake –build build –config Release
- … run some shell scripts already included in the docker image
My Problems are :
The Azure Container Instance does not support parameters like docker -it and –rm.
And if I use docker exec, I think it will start in every line a new instance and I can not use the results of the previous line.
Any Ideas on how to run multiple shell scripts on one instance of a docker image in a azure pipeline
2
Answers
Integrating the info of @Miao Tian-MSFT I ended with the following solution:
For this question, in fact, the
docker exec
command does not start a new instance of the container. The confusion might arise from the fact that eachdocker exec
command starts a new shell session in the running container, and these sessions are independent of each other. If you have a Docker container already running, you can usedocker exec
to run commands in that same container. If you are modifying data that are stored on the container, those changes will persist betweendocker exec
commands, as they all interact with the same container.You can also write your commands in a
script.sh
file and run the script inside the running Docker container, when you have multiple commands that need to be run in sequence or depend on each other.