EugenMayer / docker-sync

Run your application at full speed while syncing your code for development, finally empowering you to utilize docker for development under OSX/Windows/*Linux
GNU General Public License v3.0
3.53k stars 289 forks source link

Rsync error #201

Closed csandanov closed 7 years ago

csandanov commented 7 years ago

I got the following error:

$ docker-sync start                                                                                                                                           [17:32:50]
          ok  Starting rsync
rsync: failed to connect to localhost: Connection refused (61)
rsync error: error in socket IO (code 10) at /BuildRoot/Library/Caches/com.apple.xbs/Sources/rsync/rsync-51/rsync/clientserver.c(106) [sender=2.6.9]
       error  Error starting sync, exit code 10
     message
     success  Rsync server started
rsync: failed to connect to localhost: Connection refused (61)
rsync error: error in socket IO (code 10) at /BuildRoot/Library/Caches/com.apple.xbs/Sources/rsync/rsync-51/rsync/clientserver.c(106) [sender=2.6.9]
       error  Error starting sync, exit code 10
     message
     success  Starting to watch /dir - Press CTRL-C to stop

My docker-sync.yml:

syncs:
  myapp-sync:
    src: './'
    dest: '/var/www/html'
    sync_host_ip: 'localhost'
    sync_host_port: 10871
EugenMayer commented 7 years ago

use 127.0.0.1 instead of localhost, this should fix it

csandanov commented 7 years ago

Didn't help

EugenMayer commented 7 years ago

please provide more informations. Are you using docker for mac or something else.

I mean you plainly see the issue, localhost cannot be bound, either the port is already in use or something else happens while binding it. Its nothing special docker-sync does there.

You can enable the verbose mode, see configuration, to see what command is used to run the rsync bind and try it seperatly

csandanov commented 7 years ago

It seems docker-sync expects rsync daemon to be running (because of rsync://), is that so? Didn't find any mention of this.

csandanov commented 7 years ago

Ok, so it seems docker-sync starts rsync daemon via docker container. I use Docker for mac 1.12.3 and macOS Sierra 10.12.1. This is my output with a verbose mode:

$ docker-sync start
          ok  Starting rsync
          ok  myapp-sync container not running
          ok  starting myapp-sync container
     command  docker start myapp-sync
          ok  myapp-sync: starting initial sync of /project-path
     command  rsync -ap /project-path/ rsync://127.0.0.1:10872/volume
rsync: failed to connect to 127.0.0.1 (127.0.0.1): Connection refused (61)
rsync error: error in socket IO (code 10) at clientserver.c(125) [sender=3.1.2]
       error  Error starting sync, exit code 10
     message
     success  Rsync server started
     command  rsync -ap /project-path/ rsync://127.0.0.1:10872/volume
rsync: failed to connect to 127.0.0.1 (127.0.0.1): Connection refused (61)
rsync error: error in socket IO (code 10) at clientserver.c(125) [sender=3.1.2]
       error  Error starting sync, exit code 10
     message
          ok  Cli mode is auto, selecting ..
          ok  .. docker-sync
     success  Starting to watch /project-path - Press CTRL-C to stop
     command  fswatch -orIE --event AttributeModified --event Created --event Link --event MovedFrom --event MovedTo --event Renamed --event Removed --event Updated /project-path  | xargs -I -n1 docker-sync sync -n myapp-sync --config='/project-path/docker-sync.yml'

I've updated rsync to 3.1.2 via brew, so the error is a bit different now.

csandanov commented 7 years ago

I see via docker ps that rsync container always exposes port 8000. I've changed 10872 to 8000 in docker-sync.yml and tried again, now I have errors with symlinks permissions:

rsync: failed to set permissions on "vendor/bin/drupal" (in volume): Not supported (95)
rsync: failed to set permissions on "vendor/bin/drush" (in volume): Not supported (95)
rsync: failed to set permissions on "vendor/bin/drush.complete.sh" (in volume): Not supported (95)
rsync: failed to set permissions on "vendor/bin/drush.launcher" (in volume): Not supported (95)
rsync: failed to set permissions on "vendor/bin/drush.php" (in volume): Not supported (95)
rsync: failed to set permissions on "vendor/bin/php-parse" (in volume): Not supported (95)
rsync: failed to set permissions on "vendor/bin/phpdoc-md" (in volume): Not supported (95)
rsync: failed to set permissions on "vendor/bin/phpunit" (in volume): Not supported (95)
rsync: failed to set permissions on "vendor/bin/psysh" (in volume): Not supported (95)
rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1249) [sender=3.1.2]

But I guess it's another issue not related to rsync. Is there a way to change rsync's public port?

EugenMayer commented 7 years ago

Those are most probably symlinks to be binaries which are not part of you project but rather you system. Please use the issue search to find the various solutions for that. You probably want to try unison as a strategy since in becomes our new default.

Did you check the wiki already?there is a part for rsync upgrade, also check the boilerplate to ensure you basics are running and you issues are not project specific

csandanov commented 7 years ago

I've fixed the permissions problem with the exclude option.

I based my docker-sync.yml on rsync boilerplate. The description of sync_host_port option is:

# should be a unique port this sync instance uses on the host to offer the rsync service on

Ok, I will try unison but I think it still make sense to clarify about rsync port.

EugenMayer commented 7 years ago

I am not sure what you mean. You can use any particular port you like - ones which are yet not used of course. You can use 8000, 64000 or 1337 - does not matter, as long no other process binds to that port. What do you think needs clarification on this regard?

csandanov commented 7 years ago

I set sync_host_port to 10872 (and it's free) in docker-sync.yml but the rsync container ignores it and always exposes port 8000.

EugenMayer commented 7 years ago

please show this by pasting your docker-sync.yml and the output of the docker inspect sync-container i cannot reproduce this

csandanov commented 7 years ago

docker-sync.yml:

options:
  verbose: true
syncs:
  myapp-sync:
    src: './'
    dest: '/var/www/html'
    sync_host_ip: 127.0.0.1
    sync_host_port: 10872
$ docker inspect sync-container                                                                                                                              
[]
Error: No such image, container or task: sync-container
smileart commented 6 years ago

Had exactly the same issue while trying to switch from unison to rsync strategy (for test purposes) and it appeared to be my fault — I didn't stop/delete the old unison based container. After stoping all the app containers (web, db, etc.) and doing:

docker-sync stop
docker-sync clean

I started a new rsync-based one and everything worked perfectly fine.

Just wanted to leave it here for users coming from Google.

As a suggestion: probably it'd be better to check if there's a container based on a different strategy and if there is — output a friendly error/information message before even trying to use rsync with the port which is not being listened.