dockerubuntuazure-pipelinescontainersharbor

Ubuntu Docker image that equivalent to vmImage: ubuntu


I'm trying to build a Debian package on a ubuntu container job on azure pipeline.

Here is my setup:

pool: 'AWSLinux'

container: 
  image: ubuntu:20.04

But it looks ubuntu:20.04 docker image does not have some required tools installed.(SUDO,SVN,dpkg-architecture)

------Update and install packages------
/__w/_temp/40c7e2e3-ed1a-4d0f-a8da-5f7bf062cb90.sh: line 6: sudo: command not found
/__w/_temp/40c7e2e3-ed1a-4d0f-a8da-5f7bf062cb90.sh: line 7: sudo: command not found
/__w/_temp/40c7e2e3-ed1a-4d0f-a8da-5f7bf062cb90.sh: line 8: sudo: command not found
------Initialize build environment------
/__w/_temp/40c7e2e3-ed1a-4d0f-a8da-5f7bf062cb90.sh: line 11: sudo: command not found
------Build DEBIAN------
/__w/16/DEBIAN/scripts/build.includes: line 78: dpkg-architecture: command not found
../../../scripts/build_template.includes: line 118: svnversion: command not found

But I don't have these missing tools problems when building on Ubuntu vmImage like below:

pool:
  vmImage: ubuntu-20.04  

So my plan is to pull a Ubuntu Docker image somewhere that equivalent to vmImage: ubuntu, and push to my private Harbor registry to reference it in a container spec:

container:
  image: registry:ubuntu2004
  endpoint: private_harbor_connection

The question is where to find this Ubuntu Docker image that equivalent to vmImage: ubuntu? Is there any better solution for my problem? Thanks.

///////////////////////////////////////////////////////////////////

Here is updated yaml file:

trigger:
- master

pool: 'AWSLinux'

container: 
  image: ubuntu:20.04
  options: "--name sample -v /usr/bin/docker:/tmp/docker:ro"
  
steps:
- checkout: self
  lfs: true
  path: HVD
  clean: true

- script: |
    /tmp/docker exec -t -u root sample mv /etc/sudoers /etc/sudoers.bak
    /tmp/docker exec -t -u root sample apt-get -qq update
    /tmp/docker exec -t -u root sample apt-get -qq install sudo
    /tmp/docker exec -t -u root sample apt-get -qq install subversion
    /tmp/docker exec -t -u root sample apt-get -qq install dpkg-dev
    /tmp/docker exec -t -u root sample mv /etc/sudoers.bak /etc/sudoers

- script: |

    cd HVD/Sources/Proprietary/hvd-client/
  
    echo ------Update and install packages------
    sudo apt update -y
    sudo apt upgrade -y
    sudo apt install -y build-essential devscripts equivs git git-lfs

    echo ------Initialize build environment------
    sudo ./init-dev-hvd

    echo ------Build HVD------
    ./build.tp

    echo ------Build finshed------

But the second script stuck at following screen output when running the "Update and install packages" part.

Setting up tzdata (2024a-0ubuntu0.20.04) ...
debconf: unable to initialize frontend: Dialog
debconf: (Dialog frontend will not work on a dumb terminal, an emacs shell buffer, or without a controlling terminal.)
debconf: falling back to frontend: Readline
Configuring tzdata
------------------

Please select the geographic area in which you live. Subsequent configuration
questions will narrow this down by presenting a list of cities, representing
the time zones in which they are located.

  1. Africa      4. Australia  7. Atlantic  10. Pacific  13. Etc
  2. America     5. Arctic     8. Europe    11. SystemV
  3. Antarctica  6. Asia       9. Indian    12. US
Geographic area: 
##[error]The operation was canceled.

////////////////////////////////////////////////////////////

Here is updated yaml on June 5th.

trigger:
- master

pool: 'AWSLinux'

container: 
  image: ubuntu:20.04
  options: "--name sample -v /usr/bin/docker:/tmp/docker:ro"
  
steps:
- checkout: self
  lfs: true
  path: HVD
  clean: true

- script: |
    /tmp/docker exec -t -u root sample mv /etc/sudoers /etc/sudoers.bak
    /tmp/docker exec -t -u root sample apt-get -qq update
    /tmp/docker exec -t -u root sample apt-get -qq install sudo
    /tmp/docker exec -t -u root sample apt-get -qq install subversion
    /tmp/docker exec -t -u root sample apt-get -qq install dpkg-dev
    /tmp/docker exec -t -u root sample mv /etc/sudoers.bak /etc/sudoers

- script: |

    cd HVD/Sources/Proprietary/hvd-client/
  
    echo ------Update and install packages------
    sudo apt update -y
    sudo apt upgrade -y
    sudo DEBIAN_FRONTEND=noninteractive apt install -y build-essential devscripts equivs git git-lfs

    echo ------Initialize build environment------
    sudo ./init-dev-hvd

    echo ------Build HVD------
    ./build.tp

    echo ------Build finshed------

The script failed at step: "./build.tp" with below error:

------Build HVD------
No packages directory, rebuilding...
I: Cleaning hvd-client
dh clean
All build files have been removed.
I: Checking external version for hvd-client
I: This is not an external
I: Copying hvd-client
I: Checking source requirements for hvd-client
I: Checking build requirements for hvd-client
dpkg-checkbuilddeps: error: Unmet build dependencies: lbzip2 cmake qt5-default libssl-dev libpcsclite-dev libpng-dev libpulse-dev libxrandr-dev libxkbfile-dev libxcursor-dev libxt-dev chrpath python3-pip python3-venv libpython3-dev libxcb-xinerama0 libfreetype6-dev libxft-dev libqt5x11extras5-dev libxinerama-dev libudev-dev upx wmctrl libxmu-headers libxmu-dev libglib2.0-dev freerdp2-dev liblz4-tool cython3 clang-tidy-11 libuvc-dev libcups2-dev qtmultimedia5-dev qtpositioning5-dev libxext-dev libxcomposite-dev libxdamage-dev libxfixes-dev libxtst-dev libavcodec-dev libavutil-dev libicu-dev libgbm-dev libdrm-dev libjson-c-dev libopencv-dev libcurl4-openssl-dev

Solution

  • where to find this Ubuntu Docker image that equivalent to vmImage: ubuntu

    I'm afraid there is currently no docker image with the same configuration as the latest ubuntu VmImage.

    Here are the Public images on related to Microsoft-hosted agents on docker hub: Azure Pipelines Agent. But they are outdated.

    it looks ubuntu:20.04 docker image does not have some required tools installed.(SUDO,SVN,dpkg-architecture)

    To solve this issue, you can use the apt-get install command to install the required tools.

    But since this image runs as non-root, you can not directly run the command to install the tools.

    It will cause the following permission error:

    enter image description here

    You need to follow the following YAML script to install them:

    pool: 
      vmImage: ubuntu-20.04
    
    container: 
     image: ubuntu:20.04
     options: "--name sample -v /usr/bin/docker:/tmp/docker:ro"
    
    steps:
    - script: |
        /tmp/docker exec -t -u root sample mv /etc/sudoers /etc/sudoers.bak
        /tmp/docker exec -t -u root sample apt-get -qq update
        /tmp/docker exec -t -u root sample apt-get -qq install sudo
        /tmp/docker exec -t -u root sample apt-get -qq install subversion
        /tmp/docker exec -t -u root sample apt-get -qq install dpkg-dev
        /tmp/docker exec -t -u root sample mv /etc/sudoers.bak /etc/sudoers
    
    - next tasks:
    

    Then you can use the tools in the container job.

    For more detailed info, you can refer to this ticket: Can't acquire root on common container distros

    Update:

    Please select the geographic area in which you live. Subsequent configuration questions will narrow this down by presenting a list of cities, representing the time zones in which they are located.

    To solve this issue, you need to add DEBIAN_FRONTEND=noninteractive before apt install command.

    You can try to use the following yaml sample:

    trigger:
    - master
    
    pool: 'AWSLinux'
    
    container: 
      image: ubuntu:20.04
      options: "--name sample -v /usr/bin/docker:/tmp/docker:ro"
      
    steps:
    - checkout: self
      lfs: true
      path: HVD
      clean: true
    
    - script: |
        /tmp/docker exec -t -u root sample mv /etc/sudoers /etc/sudoers.bak
        /tmp/docker exec -t -u root sample apt-get -qq update
        /tmp/docker exec -t -u root sample apt-get -qq install sudo
        /tmp/docker exec -t -u root sample apt-get -qq install subversion
        /tmp/docker exec -t -u root sample apt-get -qq install dpkg-dev
        /tmp/docker exec -t -u root sample mv /etc/sudoers.bak /etc/sudoers
    
    - script: |
    
        cd HVD/Sources/Proprietary/hvd-client/
      
        echo ------Update and install packages------
        sudo apt update -y
        sudo apt upgrade -y
        sudo DEBIAN_FRONTEND=noninteractive apt install -y build-essential devscripts equivs git git-lfs
    
        echo ------Initialize build environment------
        sudo ./init-dev-hvd
    
        echo ------Build HVD------
        ./build.tp
    
        echo ------Build finshed------