Good afternoon, I have tried to make my data persistent, for wso2 api manager with docker, but I have not succeeded despite going to the paths that the documentation gives me:
I have created a docker-compose.yml file, in which I have defined the volumes, I have tried various paths, however, I can’t get any results. This is my file (The commented paths, are paths that I tried but still get the same result):
networks:
BeegonsFiware:
driver: bridge
services:
web:
build: ./dockerfiles/python
ports:
- "5000:5000"
hostname: web
expose:
- "5000"
networks:
- BeegonsFiware
redis:
image: "redis:alpine"
api-manager:
build: ./dockerfiles/apim
volumes:
- '/home/franklin/Escritorio/composetest/dockerfiles/apim/server/:/wso2am-4.0.0/repository/deployment/server/'
- '/home/franklin/Escritorio/composetest/dockerfiles/apim/tenants/:/wso2am-4.0.0/repository/tenants/'
- '/home/franklin/Escritorio/composetest/dockerfiles/apim/database/:/wso2am-4.0.0/database/'
# - wso2:/wso2am-4.0.0/
# - /home/franklin/Escritorio/composetest/dockerfiles/apim/backup/:/wso2am-4.0./
# - wso2:/wso2am-4.0.0/repository/deployment/server/
# Otras Pruebas
# - '/home/franklin/Escritorio/composetest/dockerfiles/apim/userstores/:/wso2am-4.0.0/repository/deployment/server/userstores/'
# - '/home/franklin/Escritorio/composetest/dockerfiles/apim/resources/:/wso2am-4.0.0/repository/resources/'
# - '/home/franklin/Escritorio/composetest/dockerfiles/apim/conf/:/wso2am-4.0.0/repository/conf/'
# - '/home/franklin/Escritorio/composetest/dockerfiles/apim/bin/:/wso2am-4.0.0/bin/'
ports:
- "9443:9443"
- "8280:8280"
- "8243:8243"
networks:
- BeegonsFiware
volumes:
wso2:
Doing docker compose up creates the folders I defined for the volume to be stored in, but does not save any data.
Folders before docker compose up:
Folders after docker compose up(they are empty folders):
The folders are created but no data is saved.
Then I create API’s in the api manager, but when doing docker compose down and then docker compose up, all the API’s are lost.
These are my specifications:
- Ubuntu 22.04.2 LTS
- Docker version 23.0.1, build a5ee5b1
- WSO2 API Manager: 4.0.0
The result I was expecting was all these files to be copied:
First I enter the container with:
docker exec -it <ID_CONTAINER> bash
I go to the following folder:
/home/wso2carbon/wso2am-4.0.0/repository/deployment/server
And these are the files I want to save:
- artifactMetafiles
- eventpublishers
- execution plans
- webapps
- axis2modules
- eventreceivers
- jaggeryapps
- axis2services
- eventstreams
- synapse-configs
In the following folder on my computer:
/home/franklin/Desktop/composetest/dockerfiles/apim/server
2
Answers
The correct path is the following not
/wso2am-4.0.0/repository
.Also, you may have to copy the contents from a default API Manager distribution into these directories before starting the servers, or else you will be mounting an empty directory. Also do not mount unnecessary folders, as it will impact the performance especially if your mount is located in a location like a NFS.
The persistent artifacts mentioned in the documentation are additional ones that you might want to include in the runtime. Since inbuilt sync is supported from APIM 4.0.0 onwards, you don’t need to maintain any mounts for synapse-configs or execution-plans by default. But if you have custom sequences, you might need to mount the relevant things in synapse-configs.
If you need to add additional resources to APIM as mentioned in [1], you can do so by mounting those to
/home/wso2carbon/wso2-artifact-volume
location inside the docker container with the correct relative path appended.For example,
Whatever you mount to this location will be added to APIM before the instance starts in their respective locations.
Also, if you have not configured an external database, your API related data will not be persisted since the default H2 databases will not be persisted if the container is recreated. It is recommended to use external databases (mysql, etc.) in such cases. This is not applicable for the carbon db which includes registry and indexing data which should be mounted to avoid considerable reindexing periods if you have a large number of APIs.
[1] – https://apim.docs.wso2.com/en/4.0.0/install-and-setup/setup/reference/common-runtime-and-configuration-artifacts/#persistent-runtime-artifacts