title: ZAP active scan works in desktop but fails in docker image with url_not_in_context error
body: <p>I am able to scan my API using ZAP desktop but fails with 'url_not_in_context' error in active scan from zap docker image. Context definition is exported from desktop and specified as argument to zap-api-scan.py.</p>
  <p>I am using zap2docker-stable image to scan APIs. Custom scripts are loaded for authentication httpsender.</p>
  <p>Error:
  51660 [ZAP-ProxyThread-15] WARN  org.zaproxy.zap.extension.api.API - Bad request to API endpoint [/JSON/ascan/action/scanAsUser/] from [127.0.0.1]:
  org.zaproxy.zap.extension.api.ApiException: url_not_in_context
  at org.zaproxy.zap.extension.ascan.ActiveScanAPI.scanURL(ActiveScanAPI.java:879) ~[zap-2.10.0.jar:2.10.0]
  at org.zaproxy.zap.extension.ascan.ActiveScanAPI.handleApiAction(ActiveScanAPI.java:370) ~[zap-2.10.0.jar:2.10.0]
  at org.zaproxy.zap.extension.api.API.handleApiRequest(API.java:507) [zap-2.10.0.jar:2.10.0]</p>
  <p>I have already implemented suggestion mentioned at <a href="https://stackoverflow.com/questions/63724016/zap-scan-jenkins-job-failed-url-not-in-context">ZAP SCAN: Jenkins Job failed (url_not_in_context)</a></p>
  <p><strong>Docker command</strong>:</p>
  <p>docker run -v D:/dev/cloud/zap/scripts:/zap/wrk/:rw -t owasp/zap2docker-stable zap-api-scan.py -d -t customer-api-docs.json -f openapi -r /zap/wrk/testreport.html -n customer-service.context.xml -U bob@xyz.com --hook=load-script.py -z  &quot;-addoninstall jython&quot;</p>
  <p>incregexes configuration in context file:</p>
  <pre><code>&lt;incregexes&gt;http://dev.xyz.com/customer.*&lt;/incregexes&gt;
  &lt;excregexes&gt;http://dev.xyz.com/customer/v3*&lt;/excregexes&gt;
  </code></pre>
  <p>Same configuration work in ZAP desktop.</p>
  <p>Following logs are printed at start of execution but then it continues with starting up zap, loading plugins and eventually fails. Is it expected or does it point to some issue ?</p>
  <pre><code>Jun 11, 2021 6:58:40 AM java.util.prefs.FileSystemPreferences$1 run                                              
  INFO: Created user preferences directory.                                                                        
  zap_started(&lt;zapv2.ZAPv2 object at 0x7f3750bf13d0&gt;, customer-api-docs.json)                                      
  load authentication script                                                                                       
  load http sender script                                                                                          
  2021-06-11 06:59:20,857 Number of Imported URLs: 9                                                               
  Traceback (most recent call last):                                                                               
    File &quot;/zap/zap-api-scan.py&quot;, line 484, in main                                                                 
      zap_active_scan(zap, target, scan_policy)                                                                    
    File &quot;/zap/zap_common.py&quot;, line 104, in _wrap                                                                  
      return_data = func(*args_list, **kwargs)                                                                     
    File &quot;/zap/zap_common.py&quot;, line 450, in zap_active_scan                                                        
      raise_scan_not_started()                                                                                     
    File &quot;/zap/zap_common.py&quot;, line 399, in raise_scan_not_started                                                 
      raise ScanNotStartedException('Failed to start the scan, check the log/output for more details.')            
  zap_common.ScanNotStartedException: Failed to start the scan, check the log/output for more details.             
  Found Java version 11.0.9.1                                                                                      
  Available memory: 3917 MB                                                                                        
  Using JVM args: -Xmx979m                                                                                         
  2381 [main] INFO  org.parosproxy.paros.Constant - Copying default configuration to /home/zap/.ZAP/config.xml     
  </code></pre>
  <p>Do I have to set apiKey during scan ? How do I determine apiKey of docker instance ?</p>
  <p>2021-06-11 10:33:20,894 http://localhost:46219 &quot;GET http://zap/JSON/ascan/action/scanAsUser/?apikey=&amp;url=http%3A%2F%2Fdev.xyz.com&amp;contextId=1&amp;userId=10&amp;recurse=True&amp;scanPolicyName=API-Minimal HTTP/1.1&quot; 400 89</p>
  <p>Context file:</p>
  <pre><code>&lt;configuration&gt;
      &lt;context&gt;
          &lt;name&gt;customer-service&lt;/name&gt;
          &lt;desc/&gt;
          &lt;inscope&gt;true&lt;/inscope&gt;
          &lt;incregexes&gt;http://dev.xyz.com/customer.*&lt;/incregexes&gt;
          &lt;excregexes&gt;http://dev.xyz.com/customer/v3*&lt;/excregexes&gt;
          &lt;tech&gt;
              &lt;include&gt;Db.IBM DB2&lt;/include&gt;
              &lt;include&gt;Language.JSP/Servlet&lt;/include&gt;
              &lt;include&gt;Language.Java&lt;/include&gt;
              &lt;include&gt;Language.JavaScript&lt;/include&gt;
              &lt;include&gt;OS.Linux&lt;/include&gt;
              &lt;include&gt;WS.Tomcat&lt;/include&gt;
              &lt;exclude&gt;Db&lt;/exclude&gt;
              &lt;exclude&gt;Db.CouchDB&lt;/exclude&gt;
              &lt;exclude&gt;Db.Firebird&lt;/exclude&gt;
              &lt;exclude&gt;Db.HypersonicSQL&lt;/exclude&gt;
              &lt;exclude&gt;Db.Microsoft Access&lt;/exclude&gt;
              &lt;exclude&gt;Db.Microsoft SQL Server&lt;/exclude&gt;
              &lt;exclude&gt;Db.MongoDB&lt;/exclude&gt;
              &lt;exclude&gt;Db.MySQL&lt;/exclude&gt;
              &lt;exclude&gt;Db.Oracle&lt;/exclude&gt;
              &lt;exclude&gt;Db.PostgreSQL&lt;/exclude&gt;
              &lt;exclude&gt;Db.SAP MaxDB&lt;/exclude&gt;
              &lt;exclude&gt;Db.SQLite&lt;/exclude&gt;
              &lt;exclude&gt;Db.Sybase&lt;/exclude&gt;
              &lt;exclude&gt;Language&lt;/exclude&gt;
              &lt;exclude&gt;Language.ASP&lt;/exclude&gt;
              &lt;exclude&gt;Language.C&lt;/exclude&gt;
              &lt;exclude&gt;Language.PHP&lt;/exclude&gt;
              &lt;exclude&gt;Language.Python&lt;/exclude&gt;
              &lt;exclude&gt;Language.Ruby&lt;/exclude&gt;
              &lt;exclude&gt;Language.XML&lt;/exclude&gt;
              &lt;exclude&gt;OS&lt;/exclude&gt;
              &lt;exclude&gt;OS.MacOS&lt;/exclude&gt;
              &lt;exclude&gt;OS.Windows&lt;/exclude&gt;
              &lt;exclude&gt;SCM&lt;/exclude&gt;
              &lt;exclude&gt;SCM.Git&lt;/exclude&gt;
              &lt;exclude&gt;SCM.SVN&lt;/exclude&gt;
              &lt;exclude&gt;WS&lt;/exclude&gt;
              &lt;exclude&gt;WS.Apache&lt;/exclude&gt;
              &lt;exclude&gt;WS.IIS&lt;/exclude&gt;
          &lt;/tech&gt;
          &lt;urlparser&gt;
              &lt;class&gt;org.zaproxy.zap.model.StandardParameterParser&lt;/class&gt;
              &lt;config&gt;{&quot;kvps&quot;:&quot;&amp;amp;&quot;,&quot;kvs&quot;:&quot;=&quot;,&quot;struct&quot;:[]}&lt;/config&gt;
          &lt;/urlparser&gt;
          &lt;postparser&gt;
              &lt;class&gt;org.zaproxy.zap.model.StandardParameterParser&lt;/class&gt;
              &lt;config&gt;{&quot;kvps&quot;:&quot;&amp;amp;&quot;,&quot;kvs&quot;:&quot;=&quot;,&quot;struct&quot;:[]}&lt;/config&gt;
          &lt;/postparser&gt;
          &lt;authentication&gt;
              &lt;type&gt;4&lt;/type&gt;
              &lt;strategy&gt;EACH_RESP&lt;/strategy&gt;
              &lt;pollurl/&gt;
              &lt;polldata/&gt;
              &lt;pollheaders/&gt;
              &lt;pollfreq&gt;60&lt;/pollfreq&gt;
              &lt;pollunits&gt;REQUESTS&lt;/pollunits&gt;
              &lt;loggedin&gt;HTTP\/1.1\s(200|404|400|500|403)&lt;/loggedin&gt;
              &lt;loggedout&gt;HTTP\/1.1\s401&lt;/loggedout&gt;
              &lt;script&gt;
                  &lt;name&gt;oidc_ropc_script&lt;/name&gt;
                  &lt;params&gt;Y2xpZW50SWQ=:cnhub3Zh&lt;/params&gt;
              &lt;/script&gt;
          &lt;/authentication&gt;
          &lt;users&gt;
              &lt;user&gt;10;true;Ym9iQHNzYy5jb20=;4;cGFzc3dvcmQ=:d2VsY29tZTE=&amp;amp;dXNlcm5hbWU=:Ym9iQHNzYy5jb20=&lt;/user&gt;
          &lt;/users&gt;
          &lt;forceduser&gt;10&lt;/forceduser&gt;
          &lt;session&gt;
              &lt;type&gt;1&lt;/type&gt;
          &lt;/session&gt;
          &lt;authorization&gt;
              &lt;type&gt;0&lt;/type&gt;
              &lt;basic&gt;
                  &lt;header/&gt;
                  &lt;body/&gt;
                  &lt;logic&gt;AND&lt;/logic&gt;
                  &lt;code&gt;-1&lt;/code&gt;
              &lt;/basic&gt;
          &lt;/authorization&gt;
      &lt;/context&gt;
  &lt;/configuration&gt;
  </code></pre>
  <p>What am I missing ?</p>