Open antejavor opened 1 month ago
Please add docker version for env flags: https://github.com/memgraph/documentation/pull/691/files#diff-3d9eed09cb1145f8eca058ea41ee667ced86663f6d04c5a291f19f278cbc7474R367
FLAGS + CONFIG FILE UPDATE
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
)docker ps
(get container id)
docker exec -it <container_id> bash
apt-get update && apt-get install -y vim
vim /etc/memgraph/memgraph.conf
DEBUG
and save memgraph.conf
docker restart <container_id>
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:
FROM memgraph/memgraph-mage:latest
COPY ./new.conf /etc/memgraph/new.conf
ENV MEMGRAPH_CONFIG=/etc/memgraph/new.conf
docker build -t my-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.
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. .
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.
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?
Related: https://github.com/memgraph/documentation/pull/691/files#r1567170751