Previous Next JavaScript must be enabled to correctly display this content

## Start KVLite in a Container

This section explains how to start KVLite in a container.

1. Pull the Oracle NoSQL Database Container Image
   The steps outlined below use the Oracle NoSQL Database Community Edition. You can pull the image directly from the GitHub Container Registry. Here, we are pulling the non-secure image.

       docker pull ghcr.io/oracle/nosql:latest-ce
       docker tag ghcr.io/oracle/nosql:latest-ce oracle/nosql:ce

2. Run Oracle NoSQL Database in a Container
   You must provide a name and a hostname.

       docker run -d --name=kvlite --hostname=kvlite --env KV_PROXY_PORT=8080 -p 8080:8080 oracle/nosql:ce

   Output:
   KVLite is started in a container and the ID of the container is displayed.

       19001d44b56aa9a53c75cf0904298c4e0e3013df287e4a8f83ebff2e1b0ac172

   By default, the KVLite store that is created has a size of 10 GB. You can use `--env KV_STORAGESIZE=N` to set a new value, where N is in gigabytes and must have a value greater than 1.
3. Check the Status of the Container
   To check the status of the container, run the following command:

       docker ps

   Output:
   The details of the container are displayed.

       CONTAINER ID   IMAGE              COMMAND                  CREATED           STATUS            PORTS                              NAMES
       19001d44b56a   oracle/nosql:ce    "bash -c ./start-kvl…"  6 minutes ago   Up 6 minutes 0.0.0.0:8080->8080/tcp, :::8080->8080/tcp  kvlite

4. Validate your Deployment
   You can ping the KVLite store instance using the following command

       docker exec -ti kvlite java -jar lib/kvstore.jar ping -host kvlite -port 5000

   Output:

       Pinging components of store kvstore based upon topology sequence #14
       10 partitions and 1 storage nodes
       Time: 2025-04-28 09:57:53 UTC   Version: 24.4.9
       Shard Status: healthy: 1 writable-degraded: 0 read-only: 0 offline: 0 total: 1
       Admin Status: healthy
       Zone [name=KVLite id=zn1 type=PRIMARY allowArbiters=false masterAffinity=false]   RN Status: online: 1 read-only: 0 offline: 0
       Storage Node [sn1] on kvlite: 5000    Zone: [name=KVLite id=zn1 type=PRIMARY allowArbiters=false masterAffinity=false]    Status: RUNNING   Ver: 24.4.9 2024-11-21 17:06:06 UTC  Build id: 95fa28ea4441 Edition: Community    isMasterBalanced: true      serviceStartTime: 2025-04-28 09:43:36 UTC
               Admin [admin1]          Status: RUNNING,MASTER  serviceStartTime: 2025-04-28 09:43:38 UTC       stateChangeTime: 2025-04-28 09:43:38 UTC        availableStorageSize: 2 GB
               Rep Node [rg1-rn1]      Status: RUNNING,MASTER sequenceNumber: 84 haPort: 5011 availableStorageSize: 9 GB storageType: HD       serviceStartTime: 2025-04-28 09:43:39 UTC stateChangeTime: 2025-04-28 09:43:39 UTC

5. Query the Database
   You can start the SQL shell to query the database and create few tables.

       docker exec -ti kvlite  java -jar lib/sql.jar -helper-hosts kvlite:5000 -store kvstore

   The SQL prompt is displayed.

       sql->

   Enter the SQL query to create a table named `ticket`.

       sql->create table if not exists ticket(ticketNo LONG, confNo STRING, PRIMARY KEY(ticketNo))

   Output:
   The table is created successfully

       Statement completed successfully

   Enter the query to show the list of tables

       sql->show tables

   Output:
   The table `ticket` that you just created is listed.

       tables
         SYS$IndexStatsLease
         SYS$MRTableAgentStat
         SYS$MRTableInfo
         SYS$MRTableInitCheckpoint
         SYS$PartitionStatsLease
         SYS$SGAttributesTable
         SYS$StreamRequest
         SYS$StreamResponse
         SYS$TableMetadata
         SYS$TableStatsIndex
         SYS$TableStatsPartition
         SYS$TopologyHistory
         ticket