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

It does not work in Mac. #8

Open
luozhucheng opened this issue Nov 27, 2020 · 3 comments
Open

It does not work in Mac. #8

luozhucheng opened this issue Nov 27, 2020 · 3 comments

Comments

@luozhucheng
Copy link

It does not work in Mac.

@Tatikoma
Copy link

Tatikoma commented Feb 27, 2022

Just tested it on Mac M1 and it works.

I have patched hoster.py to make it works, i have replaced:

shutil.move(aux_file_path, hosts_path)

to:

shutil.copyfile(aux_file_path, hosts_path)

File move doesnt work with error - resource busy. This change makes operation not atomic, but it works.

To make it work with modified code i have reassembled package:

docker build -t docker-hoster-mac .

Also i have allowed my user to edit hosts file:

sudo chmod +a "$USER allow read,write" /private/etc/hosts

Finally i runned modified container (/etc/hosts replaced with /private/etc/hosts, be careful):

docker run --restart always --name docker-hoster-mac -d \
    -v /var/run/docker.sock:/tmp/docker.sock \
    -v /private/etc/hosts:/tmp/hosts \
    docker-hoster-mac

And now it works fine.

Here is my Mac

$ sw_vers
ProductName:	macOS
ProductVersion:	12.2.1
BuildVersion:	21D62

$ docker --version
Docker version 20.10.12, build e91ed57

$ uname -a
Darwin hostname 21.3.0 Darwin Kernel Version 21.3.0: Wed Jan  5 21:37:58 PST 2022; root:xnu-8019.80.24~20/RELEASE_ARM64_T6000 arm64

@dvddarias could u do please something with it to make your repository compatible with Mac OS? Thanks in advance.

@Tatikoma
Copy link

I have thinked about my changes in code. It doesnt change anything, except adding MacOS support.

shutil.move wasnt be atomic, cuz it different filesystems (hosts file is mounted), so only way shutil can move file to differrent filesystem - copy entire contents.

I guess this fix could be applied to upstream.

@brianvh
Copy link

brianvh commented Sep 22, 2022

@Tatikoma I'm running into this same problem and would very much like to apply your fix, but I'm too much of a Docker-newbie to follow how I would make the python change to my local setup. Do I find where the local module is located and change it in place? Do I close this repo, change it, and somehow make my local setup use that? These are both things I've not done, so I'm at a bit of a loss for how to make this happen.

Would appreciate any pointers, as I'm in a situation where this library would be a massive help, if I can get it working…

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

3 participants