# Copy dump file to docker container and load it on startup

**URL:** <https://community.neo4j.com/t/copy-dump-file-to-docker-container-and-load-it-on-startup/36816>\
**Category:** Import / Export\
**Tags:** docker\
**Created:** [April 13, 2021, 4:08pm UTC](https://community.neo4j.com/t/copy-dump-file-to-docker-container-and-load-it-on-startup/36816 "2021-04-13T16:08:03Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![harald.pehl](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/harald.pehl/32/17771_2.png) [@harald.pehl](https://community.neo4j.com/u/harald.pehl)\
**Post date:** [April 13, 2021, 4:08pm UTC](https://community.neo4j.com/t/copy-dump-file-to-docker-container-and-load-it-on-startup/36816/1 "2021-04-13T16:08:03Z")

</div>

Hi,

I'd like to copy a dump file to a docker container and load it using `neo4j-admin load` as part of an extension script in my docker container.

In particular I have the following workflow

Start an empty Neo4j community instance:

```auto
docker run \
  --detach \
  --name=neo4j-analyse \
  --publish=7687:7687 \
  --volume=$PWD/data:/data \
  --env NEO4J_AUTH=neo4j/neo5j \
  neo4j

```

Run a process which populates the database

Stop the `neo4j-analyse` instance:

```auto
docker stop neo4j-analyse

```

Dump the data to a local file:

```auto
docker run --interactive --tty --rm \
  --volume=$PWD/data:/data \
  --volume=$PWD/dump:/dump \
  --user="$(id -u):$(id -g)" \
  neo4j \
  neo4j-admin dump --database=neo4j --to=/dump/db.dump

```

Build a Neo4j image which contains the dump file and populates the database at startup:

```auto
docker build --tag neo4j-model .

```

The directory for the docker build contains the dump file `db.dump`, the `Dockerfile`:

```auto
FROM neo4j

COPY db.dump /db.dump
COPY extension-script.sh /extension-script.sh
ENV EXTENSION_SCRIPT=/extension-script.sh

```

and the `extension-script.sh`:

```auto
#!/bin/sh
neo4j-admin load --from=/db.dump --database=neo4j --force

```

Start the final docker container:

```auto
docker run \
  --detach \
  --name=neo4j-model \
  --publish=7474:7474 --publish=7687:7687 \
  --env NEO4J_AUTH=none \
  --env NEO4J_dbms_read__only=true \
  neo4j-model

```

I can see in the log that the dump file is loaded and Neo4j is started. If I want to connect with the Neo4j browser, I get the following error:

```auto
ERROR DatabaseNotFoundError
Database "neo4j" is unavailable, its status is "offline."

```

What am I doing wrong? Any hints suggestions and ideas are highly appreciated!

Thanks Harald

---

<div class="post-metadata">

**Author:** ![harald.pehl](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/harald.pehl/32/17771_2.png) [@harald.pehl](https://community.neo4j.com/u/harald.pehl)\
**Post date:** [April 14, 2021, 8:27am UTC](https://community.neo4j.com/t/copy-dump-file-to-docker-container-and-load-it-on-startup/36816/2 "2021-04-14T08:27:51Z")

</div>

I was able to solve my problem, using a custom entrypoint in my Dockerfile.

For those interested, here are links to the Dockerfile and the custom entrypoint:

> <https://github.com/model-graph-tools/analyzer/blob/main/src/main/docker/neo4j/Dockerfile>

> <https://github.com/model-graph-tools/analyzer/blob/main/src/main/docker/neo4j/mgt-entrypoint.sh>

---

<div class="post-metadata">

**Author:** ![naman](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/naman/32/4404_2.png) [@naman](https://community.neo4j.com/u/naman)\
**Post date:** [October 12, 2021, 2:37pm UTC](https://community.neo4j.com/t/copy-dump-file-to-docker-container-and-load-it-on-startup/36816/3 "2021-10-12T14:37:44Z")

</div>

Hey thanks, this works perfectly!!  
The only issue is I cannot write to my database, so when i try setting  
ENV NEO4J\_dbms\_read\_\_only=false or ENV NEO4J\_writable = true , I am unable to load the data as it gives me the error that neo4j is running, then when i run "neo4j stop" the same error still persists!

---

<div class="post-metadata">

**Author:** ![naman](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/naman/32/4404_2.png) [@naman](https://community.neo4j.com/u/naman)\
**Post date:** [October 12, 2021, 2:39pm UTC](https://community.neo4j.com/t/copy-dump-file-to-docker-container-and-load-it-on-startup/36816/4 "2021-10-12T14:39:30Z")

</div>

Also when I use the second method of custom entrypoint, the data is loaded in the neo4j database but the container closes and I cannot open neo4j-browser at my localhost!!
