RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 1148794 - Running domainname in unprivileged container fails with "you must be root"
Summary: Running domainname in unprivileged container fails with "you must be root"
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: docker
Version: 7.0
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: rc
: ---
Assignee: Daniel Walsh
QA Contact: Virtualization Bugs
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2014-10-02 11:36 UTC by Jan Pazdziora
Modified: 2019-03-06 02:06 UTC (History)
1 user (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2014-10-03 15:57:32 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)

Description Jan Pazdziora 2014-10-02 11:36:30 UTC
Description of problem:

Running domainname in unprivileged container fails with

domainname: you must be root to change the domain name

Version-Release number of selected component (if applicable):

docker-1.2.0-1.5.el7.x86_64 on the host

How reproducible:

Deterministic

Steps to Reproduce:
1. docker run -ti rhel7 bash -c 'yum install -y hostname ; domainname example.test'
2. echo $?

Actual results:

# docker run -ti rhel7 bash -c 'yum install -y hostname ; domainname example.test'
rhel-7-server-rpms                                      | 3.7 kB  00:00:00     
rhel-7-server-rpms/7Server/x86_64/primary_db            | 6.7 MB  00:00:02     
[...]
Complete!
domainname: you must be root to change the domain name
# echo $?
1
#

Expected results:

# docker run -ti rhel7 bash -c 'yum install -y hostname ; domainname example.test'
rhel-7-server-rpms                                      | 3.7 kB  00:00:00     
rhel-7-server-rpms/7Server/x86_64/primary_db            | 6.7 MB  00:00:02     
[...]
Complete!
# echo $?
0
#

Additional info:

Comment 1 Jan Pazdziora 2014-10-02 11:38:34 UTC
Strace shows

brk(0)                                  = 0xd4b000
setdomainname("example.test", 12)       = -1 EPERM (Operation not permitted)
write(2, "domainname: ", 12domainname: )            = 12
write(2, "you must be root to change the d"..., 42you must be root to change the domain name) = 42

Comment 3 Daniel Walsh 2014-10-03 15:57:32 UTC
This is not a bug.  You are not allowed to change the domainname or hostname from within a container.

Comment 4 Jan Pazdziora 2014-10-03 16:10:45 UTC
(In reply to Daniel Walsh from comment #3)
> This is not a bug.  You are not allowed to change the domainname or hostname
> from within a container.

Does it apply to the NIS/YP domain name as well? That's what domainname changes. It's not dealing with DNS hostname/domain name.

Comment 5 Daniel Walsh 2014-10-11 15:33:06 UTC
Yes, you would need to set these domains outside of the container, in the docker command. Or run with the sys_admin or maybe net_admin capability.


Note You need to log in before you can comment on or make changes to this bug.