memgraph / documentation

The official documentation for Memgraph open-source graph database.
https://memgraph.com/docs
MIT License
9 stars 5 forks source link

Check the docker config changes #696

Open antejavor opened 1 month ago

antejavor commented 1 month ago

Related: https://github.com/memgraph/documentation/pull/691/files#r1567170751

antejavor commented 1 month ago

Please add docker version for env flags: https://github.com/memgraph/documentation/pull/691/files#diff-3d9eed09cb1145f8eca058ea41ee667ced86663f6d04c5a291f19f278cbc7474R367

katarinasupe commented 1 month ago

FLAGS + CONFIG FILE UPDATE

  1. Started Memgraph with log level and telemetry set docker run -p 7687:7687 -p 7444:7444 memgraph/memgraph-mage --telemetry-enabled=false --log-level=TRACE All is applied well (check with SHOW CONFIG)
  2. Enter the container and install vim docker ps(get container id) docker exec -it <container_id> bash apt-get update && apt-get install -y vim
  3. Edit config file vim /etc/memgraph/memgraph.conf
  4. Change log level to DEBUG and save memgraph.conf
  5. Restart the container docker restart <container_id>
  6. Run SHOW CONFIG - log level is set to TRACE because of the flags left in the docker run command

-> My conclusion: Flags from docker run command overwrite anything defined in the config file. It's easier to set config via flags in Docker.

PASSING NEW CONFIG FILE When passing file to MEMGRAPH_CONFIG env var, I am facing similar issues as with init file - new conf file has to be inside the Docker container and Memgraph has to be started with the correctly set MEMGRAPH_CONFIG env var. Conclusion:

  1. Create Dockerfile
    FROM memgraph/memgraph-mage:latest
    COPY ./new.conf /etc/memgraph/new.conf
    ENV MEMGRAPH_CONFIG=/etc/memgraph/new.conf
  2. Build Docker image docker build -t my-image .
  3. Run the image docker run -p 7687:7687 -p 7444:7444 my-image

Another idea was to set env var to future path in advance, c/p new conf to a running Docker container and restart the db. That does not work:

Assertion failed in file  at line 38.
    Expression: 'fs::exists(path)'
    Message: 'MEMGRAPH_CONFIG environment variable set to nonexisting path: /etc/memgraph/new.conf'

NEW CONFIG FILE + FLAGS Flags override new config file set via env var.


Based on the above, I would recommend Docker users to change config using the flags, if possible. This would be recommended for sensitive information such as username/password, but other than that, it's easier. I can document the above, but best practice is surfacing here somehow.

antejavor commented 1 month ago

FLAGS + CONFIG FILE UPDATE -> This is reasonable to me because you are changing one or two flags based on the startup-config.

PASSING NEW CONFIG FILE -> I think this can be achieved like this:

docker create --name memgraph_container -p 7687:7687 memgraph/memgraph --flag-file=/etc/memgraph/my.conf 

docker cp my.conf memgraph_container:/etc/memgraph/my.conf

docker start memgraph_container

The key is to first create a container pointing to non-existent file, paste a file and then start.

Obviously, it's not critical, but it's useful for deployment if a company uses a lot of custom flags, and want to version the config files, very relevant for HA and replicaiton due to increased number of flags. .

katarinasupe commented 1 month ago

What you suggested works well and seems like a better approach than with Dockerfile. I like it. I checked, and it works with MEMGRAPH_CONFIG env var as well.

katarinasupe commented 1 month ago

FLAGS + CONFIG FILE UPDATE -> This is reasonable to me because you are changing one or two flags based on the startup-config.

PASSING NEW CONFIG FILE -> I think this can be achieved like this:

docker create --name memgraph_container -p 7687:7687 memgraph/memgraph --flag-file=/etc/memgraph/my.conf 

docker cp my.conf memgraph_container:/etc/memgraph/my.conf

docker start memgraph_container

The key is to first create a container pointing to non-existent file, paste a file and then start.

Obviously, it's not critical, but it's useful for deployment if a company uses a lot of custom flags, and want to version the config files, very relevant for HA and replicaiton due to increased number of flags. .

I will then add this as a possibility on config page. On a separate Docker page for deployment, I will recommend setting config with flags as a best practice/easiest approach. Wdyt?