EugenMayer/docker-sync · error

Failed to start unison container in time, try to increase ma

Error message

Failed to start unison container in time, try to increase max_attempt (currently #{max_attempt}) in your configuration. See https://github.com/EugenMayer/docker-sync/wiki/2.-Configuration for more informations

What it means

Error "Failed to start unison container in time, try to increase max_attempt (currently #{max_attempt}) in your configuration. See https://github.com/EugenMayer/docker-sync/wiki/2.-Configuration for more informations" thrown in EugenMayer/docker-sync.

Source

Thrown at lib/docker-sync/sync_strategy/unison.rb:233

          cmd = "docker exec #{container_name} supervisorctl restart unison"
        end
        say_status 'command', cmd, :white if @options['verbose']
        `#{cmd}` || raise('Start failed')
        say_status 'ok', "starting initial sync of #{container_name}", :white if @options['verbose']
        # wait until container is started, then sync:
        sync_host_port = get_host_port(get_container_name, UNISON_CONTAINER_PORT)
        cmd = "unison -testserver \"#{@options['src']}\" \"socket://#{@options['sync_host_ip']}:#{sync_host_port}\""
        say_status 'command', cmd, :white if @options['verbose']
        attempt = 0
        max_attempt = @options['max_attempt'] || 5
        loop do
          # noinspection RubyUnusedLocalVariable
          stdout, stderr, exit_status = Open3.capture3(cmd)
          break if exit_status == 0

          attempt += 1
          if attempt > max_attempt
            raise "Failed to start unison container in time, try to increase max_attempt (currently #{max_attempt}) in your configuration. See https://github.com/EugenMayer/docker-sync/wiki/2.-Configuration for more informations"
          end

          sleep 1
        end
        sync
        say_status 'success', 'Unison server started', :green
      end

      # noinspection RubyUnusedLocalVariable
      def get_host_port(container_name, _container_port)
        cmd = 'docker inspect --format=\'{{(index (index .NetworkSettings.Ports "5000/tcp") 0).HostPort}}\' ' + container_name
        say_status 'command', cmd, :white if @options['verbose']
        stdout, stderr, exit_status = Open3.capture3(cmd)
        unless exit_status.success?
          say_status 'command', cmd
          say_status 'error', "Error getting mapped port, exit code #{$?.exitstatus}", :red
          say_status 'message', stderr
        end

View on GitHub (pinned to 4eab6de164)

Solutions

  1. Increase max_attempt in docker-sync.yml so the unison container has more time to become ready
  2. Check the unison container logs with 'docker logs <sync_name>' to find why startup is slow or failing
  3. Verify the unison docker image is pulled and the sync src path is valid
  4. Remove stale containers and volumes with 'docker-sync clean' and start again

Example fix

sync_options:
  max_attempt: 20

When it happens

Trigger: Thrown at lib/docker-sync/sync_strategy/unison.rb:233 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of EugenMayer/docker-sync@4eab6de164 (2026-08-23). Data as JSON: /api/errors/bfe187dcd158bd12. Report an issue: GitHub.