Skip to content

Commit 4e23452

Browse files
Add docker compose documentation (#1804)
https://trello.com/c/MgmtbjRJ/1470-support-docker-secrets * Adds documentation for general docker compose usage * Adds documentation for using secrets with neo4j --------- Co-authored-by: Reneta Popova <[email protected]>
1 parent 585f4ca commit 4e23452

File tree

3 files changed

+109
-0
lines changed

3 files changed

+109
-0
lines changed

modules/ROOT/content-nav.adoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
** xref:docker/mounting-volumes.adoc[]
2222
** xref:docker/configuration.adoc[]
2323
** xref:docker/plugins.adoc[]
24+
** xref:docker/docker-compose-standalone.adoc[]
2425
** xref:docker/clustering.adoc[]
2526
** xref:docker/operations.adoc[]
2627
** xref:docker/dump-load.adoc[]
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
:description: Running Neo4j in a Docker container using Docker Compose
2+
[[docker-compose-neo4j-standalone]]
3+
= Deploy a Neo4j standalone server using Docker Compose
4+
5+
You can deploy a Neo4j standalone server using Docker Compose by defining the container configuration in a _docker-compose.yml_ file and authenticating with basic authentication or Docker secrets.
6+
7+
[[docker-compose-basic-authentication]]
8+
== Deploy a Neo4j server using basic authentication mechanism
9+
10+
Before you start, verify that you have installed Docker Compose.
11+
For more information, see the https://docs.docker.com/compose/install/[Install Docker Compose official documentation].
12+
13+
. Create a project folder where you will store your _docker-compose.yml_ file and run your Neo4j server.
14+
. Prepare your _docker-compose.yml_ file using the following example.
15+
For more information, see the Docker Compose official documentation on https://docs.docker.com/compose/compose-file/#service-configuration-reference[Docker Compose specification].
16+
+
17+
.Example of a _docker-compose.yml_ file
18+
[source,yaml,subs="attributes+,+macros"]
19+
----
20+
services:
21+
neo4j:
22+
image: neo4j:latest
23+
volumes: # <1>
24+
- /$HOME/neo4j/logs:/logs
25+
- /$HOME/neo4j/config:/config
26+
- /$HOME/neo4j/data:/data
27+
- /$HOME/neo4j/plugins:/plugins
28+
environment:
29+
- NEO4J_AUTH=neo4j/your_password # <2>
30+
ports:
31+
- "7474:7474"
32+
- "7687:7687"
33+
restart: always
34+
----
35+
<1> Mount the _/$HOME/neo4j/<..>:_ directories to local directories on your host machine to store logs, configuration, data, and plugins.
36+
For more information about mounting volumes, see xref:docker/mounting-volumes.adoc[].
37+
<2> Set the `neo4j` username and password.
38+
39+
. Deploy your Neo4j server by running `docker-compose up` from your project folder.
40+
+
41+
[source,shell,subs="attributes+,+macros"]
42+
----
43+
docker-compose up -d
44+
----
45+
+
46+
The `-d` flag starts the container in detached mode.
47+
48+
[role=label--recommended]
49+
[[docker-compose-secrets]]
50+
== Deploy a Neo4j server with Docker secrets
51+
52+
It is advisable not to store sensitive information, such as the database username and password, in the _docker-compose.yml_ file.
53+
You can instead store your credentials in files and use them in your _docker-compose.yml_ file without exposing their values.
54+
55+
. Create a file, for example, _neo4j_auth.txt_, containing the username and password for the Neo4j server to be used as a Docker secret.
56+
+
57+
[source,text,subs="attributes"]
58+
----
59+
neo4j:your_password
60+
----
61+
. Prepare your _docker-compose.yml_ file using the following example.
62+
For more information, see the Docker Compose official documentation on https://docs.docker.com/compose/compose-file/#service-configuration-reference[Docker Compose specification].
63+
+
64+
.Example of a _docker-compose.yml_ file
65+
[source,yaml,subs="attributes+,+macros"]
66+
----
67+
services:
68+
neo4j:
69+
image: neo4j:latest
70+
volumes: # <1>
71+
- /$HOME/neo4j/logs:/logs
72+
- /$HOME/neo4j/config:/config
73+
- /$HOME/neo4j/data:/data
74+
- /$HOME/neo4j/plugin:/plugins
75+
environment:
76+
- NEO4J_AUTH_FILE=/run/secrets/neo4j_auth_file # <2>
77+
ports:
78+
- "7474:7474"
79+
- "7687:7687"
80+
restart: always
81+
secrets:
82+
- neo4j_auth_file #<3>
83+
secrets:
84+
neo4j_auth_file: # <4>
85+
file: ./neo4j_auth.txt # <5>
86+
----
87+
<1> Mount the _/$HOME/neo4j/<..>:_ directories to local directories on your host machine to store logs, configuration, data, and plugins.
88+
<2> Path to the file where the value for the `NEO4J_AUTH` environment variable can be found.
89+
<3> The name of the secret, for example `neo4j_auth_file`.
90+
<4> Path to the _neo4j_auth.txt_ file.
91+
<5> The name of the secret in the `neo4j` service.
92+
+
93+
[WARNING]
94+
====
95+
The secret value overrides the equivalent environment variable if they are both defined.
96+
So, for example, if you also define an environment variable `NEO4J_AUTH=neo4j/your_other_password` in the `environment` section of the `neo4j` service, the value of `NEO4J_AUTH_FILE` will be the one used.
97+
====
98+
99+
. Deploy your Neo4j server by running `docker-compose up` from your project folder.
100+
+
101+
[source,shell,subs="attributes+,+macros"]
102+
----
103+
docker-compose up -d
104+
----
105+
+
106+
The `-d` flag starts the container in detached mode.

modules/ROOT/pages/docker/index.adoc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,15 @@ This chapter describes the following:
1010
* xref:docker/mounting-volumes.adoc[Persisting data with Docker volumes] -- How and where to mount persistent storage to the Docker container.
1111
* xref:docker/configuration.adoc[Modify the default configuration] -- How to configure Neo4j to run in a Docker container.
1212
* xref:docker/plugins.adoc[Plugins] -- How to load plugins when using Neo4j in Docker.
13+
* xref:docker/docker-compose-standalone.adoc[Deploy a Neo4j server with Docker Compose] -- How to set up a Neo4j server with Docker Compose using a basic authentication mechanism or Docker secrets.
1314
* xref:docker/clustering.adoc[Deploy a Neo4j cluster on Docker] -- How to set up and deploy a Neo4j cluster on Docker.
1415
* xref:docker/operations.adoc[Docker specific operations] -- Descriptions of various `neo4j-admin` and `cypher-shell` operations that are specific to using Docker.
1516
* xref:docker/dump-load.adoc[Offline dump and load] -- How to perform dump and load of a containerized Neo4j database.
1617
* xref:docker/backup-restore.adoc[Online backup and restore] -- How to perform backup and restore of a containerized Neo4j database. Enterprise Only.
1718
* xref:docker/security.adoc[Security] -- Information about using encryption with a Neo4j Docker image.
1819
* xref:docker/ref-settings.adoc[Docker specific configuration settings] -- A conversion table for the Neo4j configuration settings to Docker format.
1920
21+
2022
[NOTE]
2123
====
2224
Docker does not run natively on macOS or Windows.

0 commit comments

Comments
 (0)