Configuring a Container Repository
About this task
When running webMethods API Gateway and Elasticsearch as Docker containers, you need to configure volume mapping for Elasticsearch to properly handle backups.
To configure a container repository
Procedure
-
Define volume mapping in Docker.
-
Set the backup location as an environment variable. Use the
path.repo
environment variable to define the backup location inside the Elasticsearch container. -
Apply Volume Mapping. Use Docker's volume mapping to link a host directory or named
volume to the Elasticsearch container's backup directory.
A sample Docker command to define volume mapping is as follows:
docker run -d \ -e path.repo=/usr/share/elasticsearch/backup \ -v mybckvolume:/usr/share/elasticsearch/backup \ --name elasticsearch \ docker.elastic.co/elasticsearch/elasticsearch:8.2.3
In this command:
-e path.repo=/usr/share/elasticsearch/backup
: Sets thepath.repo
environment variable to define the backup location inside the container.-v mybckvolume:/usr/share/elasticsearch/backup
: Maps the named volumemybckvolume
to the container's/usr/share/elasticsearch/backup
directory.--name elasticsearch
: Names the containerelasticsearch
.docker.elastic.co/elasticsearch/elasticsearch:8.2.3
: Specifies the Elasticsearch Docker image and version.
-
Set the backup location as an environment variable. Use the
-
Ensure backup location is writable.
If the backup location is not writable, you must change the ownership of the backup directory within the Elasticsearch container using the
docker exec chown
command.A sample change ownership Docker command is as follows:docker exec -it elasticsearch chown -R elasticsearch:elasticsearch /usr/share/elasticsearch/backup
In this command:
docker exec -it elasticsearch
: Runs a command inside the running Elasticsearch container interactively.chown -R elasticsearch:elasticsearch /usr/share/elasticsearch/backup
: Recursively changes the ownership of the backup directory to theelasticsearch
user.
-
Create a backup repository for containers.
A sample command to create a backup repository is as follows:
curl -si -X POST -H "content-type:application/json" -d '{"type": "fs", "settings": {"compress": "true", "location": "/usr/share/elasticsearch/backup/myrepo"}}' http://es-host:es-port/_snapshot/repo-name
In this example:
- Replace
es-host
andes-port
with the hostname and port number of your Elasticsearch instance. - Replace
repo-name
with the name you want to give to your backup repository. For example, myrepo.
- Replace