docker-hoster icon indicating copy to clipboard operation
docker-hoster copied to clipboard

It does not work in Mac.

Open luozhucheng opened this issue 4 years ago • 3 comments

It does not work in Mac.

luozhucheng avatar Nov 27 '20 07:11 luozhucheng

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 avatar Feb 27 '22 00:02 Tatikoma

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.

Tatikoma avatar Feb 27 '22 19:02 Tatikoma

@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…

brianvh avatar Sep 22 '22 23:09 brianvh