Answers: <p>Regarding to <a href="https://neo4j.com/developer/docker/" rel="nofollow noreferrer">Neo4j with Docker</a> and <a href="https://neo4j.com/docs/operations-manual/current/installation/docker/" rel="nofollow noreferrer">Insallation: Docker</a></p>
  
  <blockquote>
    <p>/data to allow the database to be persisted outside its container.</p>
    
    <p>/logs to allow access to Neo4j log files.</p>
  </blockquote>
  
  <p>I understand that we should mount the <code>/data</code> to the host machine so that the new password is persisted as the following example.</p>
  
  <pre class="lang-none prettyprint-override"><code>docker run \
      --publish=7474:7474 --publish=7687:7687 \
      --volume=/path/to/neo4j/data:/data \
      --volume=/path/to/neo4j/logs:/logs \
      neo4j:latest
  </code></pre>
  
  <p>Note, the <code>/path/to/neo4j</code> is a physical directory on the host machine.</p>
  
  <h3>Edit1</h3>
  
  <p>To set password, the <a href="https://neo4j.com/docs/operations-manual/current/installation/docker/" rel="nofollow noreferrer">Insallation: Docker</a> mentions as</p>
  
  <blockquote>
    <p>By default Neo4j requires authentication and requires you to login with <code>neo4j/neo4j</code> at the first connection and set a new password. </p>
    
    <p>You can set the password for the Docker container directly by specifying <code>--env NEO4J_AUTH=neo4j/&lt;password&gt;</code> in your run directive. Alternatively, you can disable authentication by specifying <code>--env NEO4J_AUTH=none</code> instead.</p>
  </blockquote>
  
  <p>Then the docker run should be</p>
  
  <pre class="lang-none prettyprint-override"><code>docker run \
      --publish=7474:7474 --publish=7687:7687 \
      --env NEO4J_AUTH=neo4j/&lt;password&gt; \
      --volume=/path/to/neo4j/data:/data \
      --volume=/path/to/neo4j/logs:/logs \
      neo4j:latest
  </code></pre>
  
  <p>Anyhow for the <code>/data</code>, I only achieve with mounting it to the host machine.</p>
  
Answers: CC BY-SA 4.0
Answers: 2018-08-22T06:02:09.217Z
Answers: Is there any way to write those volume options to an image, or is the only option to include the --volume switch each time the container is started.
Answers: Jacob Quisenberry
Answers: CC BY-SA 4.0
Answers: 2018-08-22T07:22:30.577Z
Answers: There is a way for setting the initial password, but I have not achieved with the `/data`. Please see my edit1.
Answers: Charlee Chitsuk
Answers: CC BY-SA 4.0
Answers: 2018-08-22T16:40:29.323Z
Answers: I think that the solution for the disabling authentication will satisfy my use case. For the problem of persisting data and settings, I suspect that I have to export a value to TAR. As far as I know there is no way to push a volume to Docker hub.
Answers: Jacob Quisenberry
Answers: CC BY-SA 4.0
Answers: 2018-08-22T05:23:22.460Z
Answers: 2018-08-22T07:21:21.473Z
Answers: 2018-08-22T07:21:21.473Z
Answers: Charlee Chitsuk
Body: <p>I am trying to create a new image based on the <code>neo4j:latest</code> image. What is the proper way to persist to a new image and run a container based on the image?</p>
  
  <p>I have these goals:</p>
  
  <ul>
  <li>Save the new password I assigned to the database.</li>
  <li>Keep data stored in the database.</li>
  </ul>
  
  <p>I am using 
      Windows 10
      Docker Community Edition Version 18.06.0-ce-win72 (19098)</p>
  
  <p>Here is what I have tried:</p>
  
  <ol>
  <li>Start a container from neo4j:latest.</li>
  </ol>
  
  <p>I used this docker-compose.yml:</p>
  
  <pre><code>version: "3"
  services:
    neo4j:
      image: neo4j:latest
      ports:
        - "7474:7474"
        - "7687:7687"    
  networks:
    webnet:
  </code></pre>
  
  <ol start="2">
  <li>Connect to neo4j using a browser. I set a new password, as is required.</li>
  </ol>
  
  <p><code>http://localhost:7474/browser/</code></p>
  
  <ol start="3">
  <li><p>Load data into the database using a script run on my host. I verified that the database now contains nodes and relationships.</p></li>
  <li><p>Commit the container to an image.</p></li>
  </ol>
  
  <p><code>docker commit --author="Jacob Quisenberry" c5c3f2998895 jquisenberry/graphdb:latest</code></p>
  
  <ol start="5">
  <li>Push the image to my repository.</li>
  </ol>
  
  <p><code>docker push jquisenberry/graphdb:latest</code></p>
  
  <ol start="6">
  <li>Run the image</li>
  </ol>
  
  <p><code>docker run --expose=7474 --expose=7687 -p 7474:7474 -p 7687:7687 jquisenberry/graphdb:latest</code></p>
  
  <ol start="7">
  <li>Connect using a browser.</li>
  </ol>
  
  <p>I expected not to have to enter a new password and for my data to be intact.Instead, I am required to enter a new password. My database now lacks nodes and relationships.</p>
  
Tags: <docker><docker-compose>
Title: Persist Changes to New Docker Image - neo4j
UserDisplayName: Jacob Quisenberry
ThreadText: # Persist Changes to New Docker Image - neo4j
  
  (Asked by: username_0 on 2018-08-21)
  
  I am trying to create a new image based on the `neo4j:latest` image. What is the proper way to persist to a new image and run a container based on the image?
  
  I have these goals:
  
  * Save the new password I assigned to the database.
  * Keep data stored in the database.
  
  I am using
  Windows 10
  Docker Community Edition Version 18.06.0-ce-win72 (19098)
  
  Here is what I have tried:
  
  1. Start a container from neo4j:latest.
  
  I used this docker-compose.yml:
  
  ```
  version: "3"
  services:
    neo4j:
      image: neo4j:latest
      ports:
        - "7474:7474"
        - "7687:7687"    
  networks:
    webnet:
  
  ```
  
  2. Connect to neo4j using a browser. I set a new password, as is required.
  
  `http://localhost:7474/browser/`
  
  3. Load data into the database using a script run on my host. I verified that the database now contains nodes and relationships.
  4. Commit the container to an image.
  
  `docker commit --author="username_0 username_0" c5c3f2998895 jquisenberry/graphdb:latest`
  
  5. Push the image to my repository.
  
  `docker push jquisenberry/graphdb:latest`
  
  6. Run the image
  
  `docker run --expose=7474 --expose=7687 -p 7474:7474 -p 7687:7687 jquisenberry/graphdb:latest`
  
  7. Connect using a browser.
  
  I expected not to have to enter a new password and for my data to be intact.Instead, I am required to enter a new password. My database now lacks nodes and relationships.
  
  **Tags:** docker, docker-compose
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2018-08-22. Score: 1 | Accepted answer
  
  Regarding to [Neo4j with Docker](https://neo4j.com/developer/docker/) and [Insallation: Docker](https://neo4j.com/docs/operations-manual/current/installation/docker/)
  
  > /data to allow the database to be persisted outside its container.
  >
  > /logs to allow access to Neo4j log files.
  
  I understand that we should mount the `/data` to the host machine so that the new password is persisted as the following example.
  
  ```none
  docker run \
      --publish=7474:7474 --publish=7687:7687 \
      --volume=/path/to/neo4j/data:/data \
      --volume=/path/to/neo4j/logs:/logs \
      neo4j:latest
  
  ```
  
  Note, the `/path/to/neo4j` is a physical directory on the host machine.
  
  ### Edit1
  
  To set password, the [Insallation: Docker](https://neo4j.com/docs/operations-manual/current/installation/docker/) mentions as
  
  > By default Neo4j requires authentication and requires you to login with `neo4j/neo4j` at the first connection and set a new password.
  >
  > 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.
  
  Then the docker run should be
  
  ```none
  docker run \
      --publish=7474:7474 --publish=7687:7687 \
      --env NEO4J_AUTH=neo4j/<password> \
      --volume=/path/to/neo4j/data:/data \
      --volume=/path/to/neo4j/logs:/logs \
      neo4j:latest
  
  ```
  
  Anyhow for the `/data`, I only achieve with mounting it to the host machine.
  
  > **Comments:**
  > **username_0**: Is there any way to write those volume options to an image, or is the only option to include the --volume switch each time the container is started.  
  > **username_1**: There is a way for setting the initial password, but I have not achieved with the `/data`. Please see my edit1.  
  > **username_0**: I think that the solution for the disabling authentication will satisfy my use case. For the problem of persisting data and settings, I suspect that I have to export a value to TAR. As far as I know there is no way to push a volume to Docker hub.  
  
  ---
  
  