Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Operation not permitted: '/tmp/hosts' #12

Open
rs-renato opened this issue Nov 14, 2021 · 1 comment
Open

Operation not permitted: '/tmp/hosts' #12

rs-renato opened this issue Nov 14, 2021 · 1 comment

Comments

@rs-renato
Copy link

MACOS

It seems not work on OS X

$ docker run -d -v /var/run/docker.sock:/tmp/docker.sock -v /etc/hosts:/tmp/hosts dvdarias/docker-hoster
5333e1b472c0d58d1b75b63d076913e8974ed74b04a820f7b55caccede76594a

$ docker logs 5333e1b472c0d

Updating hosts file with:
ip: 172.17.0.2 domains: ['vigilant_northcutt', '5333e1b472c0']
ip: 172.18.0.3 domains: {'hrs-ms-region', 'hrs-microservice-region', '65cde9c7813e'}
ip: 172.18.0.2 domains: {'d0fa9a1c14fa', 'mysql'}
Traceback (most recent call last):
File "hoster.py", line 135, in
main()
File "hoster.py", line 38, in main
update_hosts_file()
File "hoster.py", line 97, in update_hosts_file
with open(hosts_path,"r+") as hosts_file:
PermissionError: [Errno 1] Operation not permitted: '/tmp/hosts'

@Wohlie
Copy link

Wohlie commented Nov 25, 2021

Hi @rs-renato, may be sudo chflags nouappnd /etc/hosts on your host will help?

Or another solution could be:

sudo chmod -N /etc/hosts                    # Remove ACLs from file
sudo chflags nouchg /etc/hosts              # Clear the user immutable flag from file
sudo chflags norestricted /etc/hosts        # Remove the SIP protection from file
sudo xattr -d com.apple.rootless /etc/hosts # Remove SIP protection from file

But I don't have a Mac. Use these commands at your own risk, these are not tested.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants