I am trying to run test project in Azure pipeline .My project use TestContainer library for Azure cosmos that only work ubuntu 18.04 although that VmImage version deprecated in Azure hosted agent. so that is why I run it on ubuntu 18.04 docker container.
Here is my code example
pool:
vmImage: ubuntu-20.04
container:
image: dthang42c3/rootuserubuntu18.04
options: --user root --privileged
steps:
- script: |
sudo apt-get update
sudo apt-get install -y libicu60
displayName: 'Install libicu'
- script: |
sudo apt-get update
sudo apt --assume-yes install wget
displayName: 'Install wget'
- script: |
wget https://packages.microsoft.com/config/ubuntu/18.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
sudo dpkg -i packages-microsoft-prod.deb
rm packages-microsoft-prod.deb
sudo apt-get update
sudo apt-get install -y dotnet-sdk-6.0
displayName: 'Install .net'
- script: |
sudo apt-get update && sudo apt-get install -y lsb-release && sudo apt-get clean all
lsb_release -a
displayName: 'check version'
- task: DotNetCoreCLI@2
displayName: 'Restore BDD Tests'
inputs:
command: 'restore'
projects: '**/MyTest.slnf'
feedsToUse: config
nugetConfigPath: 'nuget.config'
- script: |
dotnet test Domains/MyTest.csproj
displayName: 'Run test'
At the final step, when the test run, I notice the test container show that it run in Ubuntu version 20.04 of VmImage. 
However it should have ran with version 18.04 of the docker container. You can see the step 'check version'. It show clearly that the version of the container is 18.04

How can I fix that ? can anyone help please. Thanks