0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

[neo4j] 開発環境をdockerで構築する

Last updated at Posted at 2020-03-21

はじめに

  • neo4jを使う機会があったので、手元のMacで手軽に動かしたかった
  • 手元で手軽に=Dockerでしょ。と言うことで、やってみた
  • 初期パスワード変更も行えるようにしたことが工夫点
    (これやらないと、ブラウザから変更作業が必要)
  • 何だかんだで、docker-composeから環境変数をDcokerfileに渡すのが一番ハマった。先人達の知恵に感謝

ディレクトリ構成

docker
├── docker-compose.yml
└── neo4j
    ├── Dockerfile
    ├── conf
    ├── data
    └── logs

Dockerfile

  • image build中にデフォルトユーザneo4jのパスワードを環境変数として渡せるようにしている
  • NEO4J_AUTHuser/passwordと設定するとパスワードが設定できるらしい
FROM neo4j:4.0.2
ARG NEO4J_PASSWORD
ENV NEO4J_AUTH=neo4j/${NEO4J_PASSWORD}

docker-compose.yml

version: '3.7'
services:
  db:
    build:
      context: ./neo4j
      args:
        NEO4J_PASSWORD: $NEO4J_PASSWORD
    image: hmiyakoshi0803/neo4j:4.0.2
    restart: always
    ports:
      - "7474:7474"
      - "7687:7687"
    volumes: 
      - ./neo4j/data:/data
      - ./neo4j/logs/:/logs
      - ./neo4j/conf/:/conf
    ulimits: 
      nofile:
        soft: "40000"
        hard: "40000"

起動方法

  • hogehoge部分に好きなパスワードを設定する
$ NEO4J_PASSWORD=hogehoge docker-compose up -d --build
  • 起動したか確認する
$ curl 127.0.0.1:7474
{
  "bolt_routing" : "neo4j://0.0.0.0:7687",
  "transaction" : "http://127.0.0.1:7474/db/{databaseName}/tx",
  "bolt_direct" : "bolt://0.0.0.0:7687",
  "neo4j_version" : "4.0.2",
  "neo4j_edition" : "community"
}

参考

Run Docker with Neo4j
Dockerfile ARG入門
docker-composeから環境変数をDockerfileに渡す方法

以上

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?