title: Why Neo4J docker authentication doesn't work
body: <p>I want to run a Neo4J instance through docker using a docker-compose.</p>
  
  <p><strong>docker-compose.yml</strong></p>
  
  <pre><code>version: '3'
  services:
    neo4j:
      container_name: neo4j-lab
      image: neo4j:latest
      environment:
        - NEO4J_dbms_memory_pagecache_size=2G
        - NEO4J_dbms_memory_heap_maxSize=4G
        - NEO4J_dbms_memory_heap_initialSize=512M
        - NEO4J_AUTH=neo4j/changeme
      ports:
        - 7474:7474
        - 7687:7687
      volumes:
        - neo4j_data:/data
        - neo4j_conf:/conf
        - ./import:/import
  volumes:
    neo4j_data:
    neo4j_conf:
  </code></pre>
  
  <p>Running the following with <code>docker-compose up</code> is perfectly fine, and I can reach the login screen.</p>
  
  <p>But when I set the credentials, I get the following error on my container logs : <strong>Neo.ClientError.Security.Unauthorized The client is unauthorized due to authentication failure.</strong> whereas I am sure that I fill with right credentials (the ones used in my docker-compose file)</p>
  
  <p>Furthermore, </p>
  
  <ul>
  <li><p>when I set <code>NEO4J_AUTH</code> to <code>none</code>, then no credentials have been asked.</p></li>
  <li><p>when I set it to <code>neo4j/neo4j</code> it said that I can't use the default password</p></li>
  </ul>
  
  <p>According the documentation, this is perfectly fine :</p>
  
  <blockquote>
    <p>By default Neo4j requires authentication and requires you to login with neo4j/neo4j at the first connection and set a new password. <strong>You can set the password for the Docker container directly by specifying --env NEO4J_AUTH=neo4j/password in your run directive. Alternatively, you can disable authentication by specifying --env NEO4J_AUTH=none instead.</strong></p>
  </blockquote>
  
  <p>Do you have any idea of what's going on ? </p>
  
  <p>Hope you could help me to solve this !</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>Docker logs output : </p>
  
  <pre><code>neo4j-lab | 2019-03-13 23:02:32.378+0000 INFO  Starting...
  neo4j-lab | 2019-03-13 23:02:37.796+0000 INFO  Bolt enabled on 0.0.0.0:7687.
  neo4j-lab | 2019-03-13 23:02:41.102+0000 INFO  Started.
  neo4j-lab | 2019-03-13 23:02:43.935+0000 INFO  Remote interface available at http://localhost:7474/
  neo4j-lab | 2019-03-13 23:02:56.105+0000 WARN  The client is unauthorized due to authentication failure.
  </code></pre>
  
  <p><strong>EDIT 2 :</strong></p>
  
  <p>It seems that deleting the volume associated first works. The password is now changed.</p>
  
  <p>However, if I <code>docker-compose down</code> then <code>docker-compose up</code> whereas I change the password in my <code>docker-compose file</code> then the issue reappears.</p>
  
  <p>So I think that when we change the password through docker-compose <strong>more than once</strong> while a volume exists, we need to remove the <code>auth</code> file presents in the volumes.</p>
  
  <p>To do that : </p>
  
  <pre><code>docker volume inspect &lt;volume_name&gt;
  </code></pre>
  
  <p>You should get something like that :</p>
  
  <pre><code>[
      {
          "CreatedAt": "2019-03-14T11:17:08+01:00",
          "Driver": "local",
          "Labels": {
              "com.docker.compose.project": "neo4j",
              "com.docker.compose.volume": "neo4j_data"
          },
          "Mountpoint": "/data/docker/volumes/neo4j_neo4j_data/_data",
          "Name": "neo4j_neo4j_data",
          "Options": null,
          "Scope": "local"
      }
  ]
  </code></pre>
  
  <p>This is obviously different if you named your container and your volumes not like me (neo4j, neo4j_data).</p>
  
  <p>The important part is the <strong>Mountpoint</strong> which locates the volume.</p>
  
  <p>In this volume, you can delete the <code>auth</code> file which is in <code>dbms</code> directory.</p>
  
  <p>Then restart your docker and everything should be fine.</p>