jmc
jmc

Reputation: 1729

docker-compose does not load up data

I have an existing neo4j image with data in it that I run using the following docker run command

docker run --publish=7474:7474 --volume=$HOME/neo4jdev/data:/data neo4j

When I check this in my browser at http://192.168.99.100:7474/browser/, I confirmed that my container has existing nodes in it.

What I want to do is use docker-compose instead of docker run to run my services. This is what my docker-compose.yml looks like

version: '2'
services:
  neo4jdev:
    image: neo4j
    ports: 
         - "7474:7474"
    volumes: 
         - $HOME/neo4jdev/data

I run this using docker-compose up.

But when I check my browser, I get an empty database without nodes in it. It seems to only load the latest neo4j image.

Upvotes: 0

Views: 576

Answers (1)

Bernard
Bernard

Reputation: 17311

Use this instead

volumes:
  - $HOME/neo4jdev/data:/data

So your docker-compose.yml would look like this

version: '2'
services:
  neo4jdev:
    container_name: n4j
    image: neo4j
    ports: 
         - "7474:7474"
    volumes: 
         - $HOME/neo4jdev/data:/data

docker-compose up -d

Then look at the content of your /data dir on your container using

docker exec n4j ls -al /data

This gives me

total 16
drwxr-xr-x  4 root root 4096 Sep 12 11:16 .
drwxr-xr-x 51 root root 4096 Sep 12 11:20 ..
drwxr-xr-x  3 root root 4096 Sep 12 11:16 databases
drwxr-xr-x  2 root root 4096 Sep 12 11:16 dbms

Upvotes: 3

Related Questions