Improve setup-container.sh for Ubuntu 24.04 based docker-sonic-mgmt#20761
Merged
StormLiangMS merged 1 commit intosonic-net:masterfrom Sep 23, 2025
Merged
Improve setup-container.sh for Ubuntu 24.04 based docker-sonic-mgmt#20761StormLiangMS merged 1 commit intosonic-net:masterfrom
StormLiangMS merged 1 commit intosonic-net:masterfrom
Conversation
To support docker-sonic-mgmt based on Ubuntu 24.04, the setup-container.sh needs some minor improvements: 1. The Ubuntu 24.04 docker image as account "ubuntu" by default. Its uid could conflict with the user's uid. This change added code to best effort deleting this default "ubuntu" account. 2. In old docker-sonic-mgmt, python3 is installed in virtual environment. In 2024, the docker-sonic-mgmt was updated to install python3 in global environment. It's no longer necessary to hack the virtual environment. This change adjusted the sequence of conditions for hacking venv, so that the code can fail faster to skip this step. In the future, this piece of code should can be deleted. Signed-off-by: Xin Wang <xiwang5@microsoft.com>
Collaborator
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
9 tasks
11 tasks
vidyac86
pushed a commit
to vidyac86/sonic-mgmt
that referenced
this pull request
Oct 23, 2025
…onic-net#20761) To support docker-sonic-mgmt based on Ubuntu 24.04, the setup-container.sh needs some minor improvements: 1. The Ubuntu 24.04 docker image as account "ubuntu" by default. Its uid could conflict with the user's uid. This change added code to best effort deleting this default "ubuntu" account. 2. In old docker-sonic-mgmt, python3 is installed in virtual environment. In 2024, the docker-sonic-mgmt was updated to install python3 in global environment. It's no longer necessary to hack the virtual environment. This change adjusted the sequence of conditions for hacking venv, so that the code can fail faster to skip this step. In the future, this piece of code should can be deleted. Signed-off-by: Xin Wang <xiwang5@microsoft.com>
mssonicbld
pushed a commit
that referenced
this pull request
Nov 11, 2025
…20761) To support docker-sonic-mgmt based on Ubuntu 24.04, the setup-container.sh needs some minor improvements: 1. The Ubuntu 24.04 docker image as account "ubuntu" by default. Its uid could conflict with the user's uid. This change added code to best effort deleting this default "ubuntu" account. 2. In old docker-sonic-mgmt, python3 is installed in virtual environment. In 2024, the docker-sonic-mgmt was updated to install python3 in global environment. It's no longer necessary to hack the virtual environment. This change adjusted the sequence of conditions for hacking venv, so that the code can fail faster to skip this step. In the future, this piece of code should can be deleted. Signed-off-by: Xin Wang <xiwang5@microsoft.com>
mssonicbld
pushed a commit
that referenced
this pull request
Nov 11, 2025
…20761) To support docker-sonic-mgmt based on Ubuntu 24.04, the setup-container.sh needs some minor improvements: 1. The Ubuntu 24.04 docker image as account "ubuntu" by default. Its uid could conflict with the user's uid. This change added code to best effort deleting this default "ubuntu" account. 2. In old docker-sonic-mgmt, python3 is installed in virtual environment. In 2024, the docker-sonic-mgmt was updated to install python3 in global environment. It's no longer necessary to hack the virtual environment. This change adjusted the sequence of conditions for hacking venv, so that the code can fail faster to skip this step. In the future, this piece of code should can be deleted. Signed-off-by: Xin Wang <xiwang5@microsoft.com>
mssonicbld
pushed a commit
that referenced
this pull request
Nov 11, 2025
…20761) To support docker-sonic-mgmt based on Ubuntu 24.04, the setup-container.sh needs some minor improvements: 1. The Ubuntu 24.04 docker image as account "ubuntu" by default. Its uid could conflict with the user's uid. This change added code to best effort deleting this default "ubuntu" account. 2. In old docker-sonic-mgmt, python3 is installed in virtual environment. In 2024, the docker-sonic-mgmt was updated to install python3 in global environment. It's no longer necessary to hack the virtual environment. This change adjusted the sequence of conditions for hacking venv, so that the code can fail faster to skip this step. In the future, this piece of code should can be deleted. Signed-off-by: Xin Wang <xiwang5@microsoft.com>
wangxin
pushed a commit
that referenced
this pull request
Nov 19, 2025
…20761) (#21266) To support docker-sonic-mgmt based on Ubuntu 24.04, the setup-container.sh needs some minor improvements: 1. The Ubuntu 24.04 docker image as account "ubuntu" by default. Its uid could conflict with the user's uid. This change added code to best effort deleting this default "ubuntu" account. 2. In old docker-sonic-mgmt, python3 is installed in virtual environment. In 2024, the docker-sonic-mgmt was updated to install python3 in global environment. It's no longer necessary to hack the virtual environment. This change adjusted the sequence of conditions for hacking venv, so that the code can fail faster to skip this step. In the future, this piece of code should can be deleted. Signed-off-by: Xin Wang <xiwang5@microsoft.com>
mssonicbld
pushed a commit
that referenced
this pull request
Nov 19, 2025
…20761) To support docker-sonic-mgmt based on Ubuntu 24.04, the setup-container.sh needs some minor improvements: 1. The Ubuntu 24.04 docker image as account "ubuntu" by default. Its uid could conflict with the user's uid. This change added code to best effort deleting this default "ubuntu" account. 2. In old docker-sonic-mgmt, python3 is installed in virtual environment. In 2024, the docker-sonic-mgmt was updated to install python3 in global environment. It's no longer necessary to hack the virtual environment. This change adjusted the sequence of conditions for hacking venv, so that the code can fail faster to skip this step. In the future, this piece of code should can be deleted. Signed-off-by: Xin Wang <xiwang5@microsoft.com>
mssonicbld
added a commit
to mssonicbld/sonic-buildimage
that referenced
this pull request
Dec 3, 2025
<!--
Please make sure you've read and understood our contributing guidelines:
https://github.com/Azure/SONiC/blob/gh-pages/CONTRIBUTING.md
** Make sure all your commits include a signature generated with `git commit -s` **
If this is a bug fix, make sure your description includes "fixes #xxxx", or
"closes #xxxx" or "resolves #xxxx"
Please provide the following information:
-->
#### Why I did it
The base image Ubuntu 20.04 of docker-sonic-mgmt is end of support now. Need to upgrade the base image and the dependent packages to address potential vulnerability issues.
DO NOT MERGE until sonic-net/sonic-mgmt#21045 is merged and cherry-picked to all current active branches.
##### Work item tracking
- Microsoft ADO **(number only)**:
#### How I did it
* Upgraded base image of docker-sonic-mgmt to Ubuntu 24.04.
* Upgraded the build environment to bookworm.
* Removed the logic of building flag `LEGACY_SONIC_MGMT_DOCKER`. All the sonic-mgmt branches are using python3 now. It's not necessary to build docker-sonic-mgmt to support python2. And python2 is end of support too.
* Version of python packages are not pinned down. This change has pros and cons.
* Pros: Keep the docker-sonic-mgmt up to date to avoid future big version leap which could be difficult to handle.
* Cons: Community package upgrade could have issue and cause regression.
* Version of ansible is pinned to 11.10.0. It's because pytest-ansible does not support the latest ansible due to ansible/pytest-ansible#489
* Python packages are installed to /opt/venv by following the recommendation of Ubuntu 24.04.
* The dash-api package is reverted to install from source code. The dash-api debian package built in bookworm cannot be installed in Ubuntu 24.04 due to dependency issues.
* Default user "ubuntu" of Ubuntu 24.04 is removed from the image to avoid potential issues. For details, please refer to sonic-net/sonic-mgmt#20761. Skipped adding regular user. With this change, the image will only have root user. The `setup-container.sh` tool in the sonic-mgmt repository can add regular user. Recommend to use the `setup-container.sh` tool to create sonic-mgmt container.
* Improved the code for installing docker and azure-cli.
* Remove the build dependency of the `ptf` debian package. It's because the `ptf` package is installed by python pip.
#### How to verify it
After the upgrade, there are some compatibility issues. The compatibility issues are fixed in sonic-net/sonic-mgmt#21045.
I am using that PR to verify that all PR test scripts can pass by using the upgraded docker-sonic-mgmt.
The fix in sonic-net/sonic-mgmt#21045 is backward compatible. Backward compatibility is verified by PR testing of sonic-net/sonic-mgmt#20851
<!--
If PR needs to be backported, then the PR must be tested against the base branch and the earliest backport release branch and provide tested image version on these two branches. For example, if the PR is requested for master, 202211 and 202012, then the requester needs to provide test results on master and 202012.
-->
#### Which release branch to backport (provide reason below if selected)
<!--
- Note we only backport fixes to a release branch, *not* features!
- Please also provide a reason for the backporting below.
- e.g.
- [x] 202006
-->
- [ ] 202205
- [ ] 202211
- [ ] 202305
- [ ] 202311
- [ ] 202405
- [ ] 202411
- [ ] 202505
#### Tested branch (Please provide the tested image version)
<!--
- Please provide tested image version
- e.g.
- [x] 20201231.100
-->
- [ ] <!-- image version 1 -->
- [ ] <!-- image version 2 -->
#### Description for the changelog
<!--
Write a short (one line) summary that describes the changes in this
pull request for inclusion in the changelog:
-->
<!--
Ensure to add label/tag for the feature raised. example - PR#2174 under sonic-utilities repo. where, Generic Config and Update feature has been labelled as GCU.
-->
#### Link to config_db schema for YANG module changes
<!--
Provide a link to config_db schema for the table for which YANG model
is defined
Link should point to correct section on https://github.com/Azure/sonic-buildimage/blob/master/src/sonic-yang-models/doc/Configuration.md
-->
#### A picture of a cute animal (not mandatory but encouraged)
9 tasks
opcoder0
pushed a commit
to opcoder0/sonic-mgmt
that referenced
this pull request
Dec 8, 2025
…onic-net#20761) To support docker-sonic-mgmt based on Ubuntu 24.04, the setup-container.sh needs some minor improvements: 1. The Ubuntu 24.04 docker image as account "ubuntu" by default. Its uid could conflict with the user's uid. This change added code to best effort deleting this default "ubuntu" account. 2. In old docker-sonic-mgmt, python3 is installed in virtual environment. In 2024, the docker-sonic-mgmt was updated to install python3 in global environment. It's no longer necessary to hack the virtual environment. This change adjusted the sequence of conditions for hacking venv, so that the code can fail faster to skip this step. In the future, this piece of code should can be deleted. Signed-off-by: Xin Wang <xiwang5@microsoft.com>
mssonicbld
added a commit
to sonic-net/sonic-buildimage
that referenced
this pull request
Dec 14, 2025
<!-- Please make sure you've read and understood our contributing guidelines: https://github.com/Azure/SONiC/blob/gh-pages/CONTRIBUTING.md failure_prs.log Make sure all your commits include a signature generated with `git commit -s` ** If this is a bug fix, make sure your description includes "fixes #xxxx", or "closes #xxxx" or "resolves #xxxx" Please provide the following information: --> #### Why I did it The base image Ubuntu 20.04 of docker-sonic-mgmt is end of support now. Need to upgrade the base image and the dependent packages to address potential vulnerability issues. DO NOT MERGE until sonic-net/sonic-mgmt#21045 is merged and cherry-picked to all current active branches. ##### Work item tracking - Microsoft ADO **(number only)**: #### How I did it * Upgraded base image of docker-sonic-mgmt to Ubuntu 24.04. * Upgraded the build environment to bookworm. * Removed the logic of building flag `LEGACY_SONIC_MGMT_DOCKER`. All the sonic-mgmt branches are using python3 now. It's not necessary to build docker-sonic-mgmt to support python2. And python2 is end of support too. * Version of python packages are not pinned down. This change has pros and cons. failure_prs.log Pros: Keep the docker-sonic-mgmt up to date to avoid future big version leap which could be difficult to handle. failure_prs.log Cons: Community package upgrade could have issue and cause regression. * Version of ansible is pinned to 11.10.0. It's because pytest-ansible does not support the latest ansible due to ansible/pytest-ansible#489 * Python packages are installed to /opt/venv by following the recommendation of Ubuntu 24.04. * The dash-api package is reverted to install from source code. The dash-api debian package built in bookworm cannot be installed in Ubuntu 24.04 due to dependency issues. * Default user "ubuntu" of Ubuntu 24.04 is removed from the image to avoid potential issues. For details, please refer to sonic-net/sonic-mgmt#20761. Skipped adding regular user. With this change, the image will only have root user. The `setup-container.sh` tool in the sonic-mgmt repository can add regular user. Recommend to use the `setup-container.sh` tool to create sonic-mgmt container. * Improved the code for installing docker and azure-cli. * Remove the build dependency of the `ptf` debian package. It's because the `ptf` package is installed by python pip. #### How to verify it After the upgrade, there are some compatibility issues. The compatibility issues are fixed in sonic-net/sonic-mgmt#21045. I am using that PR to verify that all PR test scripts can pass by using the upgraded docker-sonic-mgmt. The fix in sonic-net/sonic-mgmt#21045 is backward compatible. Backward compatibility is verified by PR testing of sonic-net/sonic-mgmt#20851 <!-- If PR needs to be backported, then the PR must be tested against the base branch and the earliest backport release branch and provide tested image version on these two branches. For example, if the PR is requested for master, 202211 and 202012, then the requester needs to provide test results on master and 202012. --> #### Which release branch to backport (provide reason below if selected) <!-- - Note we only backport fixes to a release branch, *not* features! - Please also provide a reason for the backporting below. - e.g. - [x] 202006 --> - [ ] 202205 - [ ] 202211 - [ ] 202305 - [ ] 202311 - [ ] 202405 - [ ] 202411 - [ ] 202505 #### Tested branch (Please provide the tested image version) <!-- - Please provide tested image version - e.g. - [x] 20201231.100 --> - [ ] <!-- image version 1 --> - [ ] <!-- image version 2 --> #### Description for the changelog <!-- Write a short (one line) summary that describes the changes in this pull request for inclusion in the changelog: --> <!-- Ensure to add label/tag for the feature raised. example - PR#2174 under sonic-utilities repo. where, Generic Config and Update feature has been labelled as GCU. --> #### Link to config_db schema for YANG module changes <!-- Provide a link to config_db schema for the table for which YANG model is defined Link should point to correct section on https://github.com/Azure/sonic-buildimage/blob/master/src/sonic-yang-models/doc/Configuration.md --> #### A picture of a cute animal (not mandatory but encouraged)
gshemesh2
pushed a commit
to gshemesh2/sonic-mgmt
that referenced
this pull request
Dec 16, 2025
…onic-net#20761) To support docker-sonic-mgmt based on Ubuntu 24.04, the setup-container.sh needs some minor improvements: 1. The Ubuntu 24.04 docker image as account "ubuntu" by default. Its uid could conflict with the user's uid. This change added code to best effort deleting this default "ubuntu" account. 2. In old docker-sonic-mgmt, python3 is installed in virtual environment. In 2024, the docker-sonic-mgmt was updated to install python3 in global environment. It's no longer necessary to hack the virtual environment. This change adjusted the sequence of conditions for hacking venv, so that the code can fail faster to skip this step. In the future, this piece of code should can be deleted. Signed-off-by: Xin Wang <xiwang5@microsoft.com> Signed-off-by: Guy Shemesh <gshemesh@nvidia.com>
AharonMalkin
pushed a commit
to AharonMalkin/sonic-mgmt
that referenced
this pull request
Dec 16, 2025
…onic-net#20761) To support docker-sonic-mgmt based on Ubuntu 24.04, the setup-container.sh needs some minor improvements: 1. The Ubuntu 24.04 docker image as account "ubuntu" by default. Its uid could conflict with the user's uid. This change added code to best effort deleting this default "ubuntu" account. 2. In old docker-sonic-mgmt, python3 is installed in virtual environment. In 2024, the docker-sonic-mgmt was updated to install python3 in global environment. It's no longer necessary to hack the virtual environment. This change adjusted the sequence of conditions for hacking venv, so that the code can fail faster to skip this step. In the future, this piece of code should can be deleted. Signed-off-by: Xin Wang <xiwang5@microsoft.com> Signed-off-by: Aharon Malkin <amalkin@nvidia.com>
gshemesh2
pushed a commit
to gshemesh2/sonic-mgmt
that referenced
this pull request
Dec 21, 2025
…onic-net#20761) To support docker-sonic-mgmt based on Ubuntu 24.04, the setup-container.sh needs some minor improvements: 1. The Ubuntu 24.04 docker image as account "ubuntu" by default. Its uid could conflict with the user's uid. This change added code to best effort deleting this default "ubuntu" account. 2. In old docker-sonic-mgmt, python3 is installed in virtual environment. In 2024, the docker-sonic-mgmt was updated to install python3 in global environment. It's no longer necessary to hack the virtual environment. This change adjusted the sequence of conditions for hacking venv, so that the code can fail faster to skip this step. In the future, this piece of code should can be deleted. Signed-off-by: Xin Wang <xiwang5@microsoft.com> Signed-off-by: Guy Shemesh <gshemesh@nvidia.com>
venu-nexthop
pushed a commit
to venu-nexthop/sonic-mgmt
that referenced
this pull request
Jan 13, 2026
…onic-net#20761) To support docker-sonic-mgmt based on Ubuntu 24.04, the setup-container.sh needs some minor improvements: 1. The Ubuntu 24.04 docker image as account "ubuntu" by default. Its uid could conflict with the user's uid. This change added code to best effort deleting this default "ubuntu" account. 2. In old docker-sonic-mgmt, python3 is installed in virtual environment. In 2024, the docker-sonic-mgmt was updated to install python3 in global environment. It's no longer necessary to hack the virtual environment. This change adjusted the sequence of conditions for hacking venv, so that the code can fail faster to skip this step. In the future, this piece of code should can be deleted. Signed-off-by: Xin Wang <xiwang5@microsoft.com>
yifan-nexthop
pushed a commit
to nexthop-ai/sonic-mgmt
that referenced
this pull request
Jan 14, 2026
…onic-net#20761) To support docker-sonic-mgmt based on Ubuntu 24.04, the setup-container.sh needs some minor improvements: 1. The Ubuntu 24.04 docker image as account "ubuntu" by default. Its uid could conflict with the user's uid. This change added code to best effort deleting this default "ubuntu" account. 2. In old docker-sonic-mgmt, python3 is installed in virtual environment. In 2024, the docker-sonic-mgmt was updated to install python3 in global environment. It's no longer necessary to hack the virtual environment. This change adjusted the sequence of conditions for hacking venv, so that the code can fail faster to skip this step. In the future, this piece of code should can be deleted. Signed-off-by: Xin Wang <xiwang5@microsoft.com> Signed-off-by: YiFan Wang <yifan@nexthop.ai>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description of PR
Summary:
Fixes # (issue)
Type of change
Back port request
Approach
What is the motivation for this PR?
To support docker-sonic-mgmt based on Ubuntu 24.04, the setup-container.sh needs some minor improvements:
How did you do it?
How did you verify/test it?
Use the updated script to setup sonic-mgmt container use both old and new docker-sonic-mgmt images.
Any platform specific information?
Supported testbed topology if it's a new test case?
Documentation