{"record":{"id":"bfe187dcd158bd12","repo":"EugenMayer/docker-sync","slug":"failed-to-start-unison-container-in-time-try-to-i","errorCode":null,"errorMessage":"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","messagePattern":"Failed to start unison container in time, try to increase max_attempt \\(currently #(.+?)\\) in your configuration\\. See https://github\\.com/EugenMayer/docker-sync/wiki/2\\.-Configuration for more informations","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"lib/docker-sync/sync_strategy/unison.rb","lineNumber":233,"sourceCode":"          cmd = \"docker exec #{container_name} supervisorctl restart unison\"\n        end\n        say_status 'command', cmd, :white if @options['verbose']\n        `#{cmd}` || raise('Start failed')\n        say_status 'ok', \"starting initial sync of #{container_name}\", :white if @options['verbose']\n        # wait until container is started, then sync:\n        sync_host_port = get_host_port(get_container_name, UNISON_CONTAINER_PORT)\n        cmd = \"unison -testserver \\\"#{@options['src']}\\\" \\\"socket://#{@options['sync_host_ip']}:#{sync_host_port}\\\"\"\n        say_status 'command', cmd, :white if @options['verbose']\n        attempt = 0\n        max_attempt = @options['max_attempt'] || 5\n        loop do\n          # noinspection RubyUnusedLocalVariable\n          stdout, stderr, exit_status = Open3.capture3(cmd)\n          break if exit_status == 0\n\n          attempt += 1\n          if attempt > max_attempt\n            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\"\n          end\n\n          sleep 1\n        end\n        sync\n        say_status 'success', 'Unison server started', :green\n      end\n\n      # noinspection RubyUnusedLocalVariable\n      def get_host_port(container_name, _container_port)\n        cmd = 'docker inspect --format=\\'{{(index (index .NetworkSettings.Ports \"5000/tcp\") 0).HostPort}}\\' ' + container_name\n        say_status 'command', cmd, :white if @options['verbose']\n        stdout, stderr, exit_status = Open3.capture3(cmd)\n        unless exit_status.success?\n          say_status 'command', cmd\n          say_status 'error', \"Error getting mapped port, exit code #{$?.exitstatus}\", :red\n          say_status 'message', stderr\n        end","sourceCodeStart":215,"sourceCodeEnd":251,"githubUrl":"https://github.com/EugenMayer/docker-sync/blob/4eab6de164d44c724c739c17bd574efa9008aae1/lib/docker-sync/sync_strategy/unison.rb#L215-L251","documentation":"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.","triggerScenarios":"Thrown at lib/docker-sync/sync_strategy/unison.rb:233 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Increase max_attempt in docker-sync.yml so the unison container has more time to become ready","Check the unison container logs with 'docker logs <sync_name>' to find why startup is slow or failing","Verify the unison docker image is pulled and the sync src path is valid","Remove stale containers and volumes with 'docker-sync clean' and start again"],"exampleFix":"sync_options:\n  max_attempt: 20","handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"4eab6de164d44c724c739c17bd574efa9008aae1","analyzedAt":"2026-08-23T10:20:11.101Z","schemaVersion":2},"datasetVersion":"2026-08-23T13:39:53.451Z"}