0

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. enter image description here

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 enter image description here

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

1
  • May I know this issue has been fixed already? I encountered the same issue while using azure pipeline template. Commented Sep 27, 2024 at 3:39

1 Answer 1

0

This seems is a known issue of Testcontainers when running tests via docker-in-docker. This issue also would occur on other CI/CD services than Azure Pipelines.

As a workaround, you can try to set the following environment variable in your Ubuntu 18.04 Docker container.

TESTCONTAINERS_HOST_OVERRIDE=host.docker.internal

OR

TESTCONTAINERS_HOST_OVERRIDE=localhost

Related articles and tickets:


Sign up to request clarification or add additional context in comments.

6 Comments

Thank for your answer. However ,after I change the environment variable TESTCONTAINERS_HOST_OVERRIDE=host.docker.internal, the pipeline got this error DotNet.Testcontainers.Containers.ResourceReaperException : Initialization has been cancelled . I tried to find a solution online. It seem I can turn off by set environment variable TESTCONTAINERS_RYUK_DISABLED=true. However then it cause the azure pipeline freeze for 60 minutes and end. Finally , in all cases I notice that the Test Container when connect to docker, it still show the ubuntu version 20.04 of the vmImage
@JNguyen, How about set "TESTCONTAINERS_HOST_OVERRIDE=localhost"?
It will cause a very strange behavior. The container got start and then stop immediately. Causing this error "Docker API responded with status code=NotFound, response={"message":"No such container: etc" .
The logs are something like this
[testcontainers.org 00:00:00.14] Docker config "/home/vsts_azpcontainer/.docker/config.json" not found [testcontainers.org 00:00:00.14] Searching Docker registry credential in Auths [testcontainers.org 00:00:00.14] Docker registry credential index.docker.io/v1 not found [testcontainers.org 00:00:01.94] Docker image testcontainers/ryuk:0.5.1 created
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.