Deploy OrientDB Container with Docker Compose


OrientDB is an open-source NoSQL (Not Only SQL) database management system that combines the features of graph databases, document-oriented databases, and object-oriented databases. It is designed to be a multi-model database, meaning it supports multiple data models, including graph, document, key/value, and object models.

Docker Compose is a tool for defining and running multi-container Docker applications. It allows you to define an entire application stack, including services, networks, and volumes, in a single file called docker-compose.yml. With a single command, you can then spin up your entire application stack, simplifying the process of managing and deploying multi-container Docker applications.


  • Up and running ubuntu 22.04 LTS machine.
  • Basic knowledge in linux commands.
  • Internet connectivity.
  • Docker and docker compose should installed on your machine.

To install Docker and docker compose on ubuntu 22.04 LTS, We can use the given link.

In this post, We will deploy OrientDB database container using Docker Compose on Ubuntu 22.04 LTS machine.

Step 1: Creating docker-compose.yml

Using Docker Compose simplifies the process of deploying and managing multi-container Docker applications. Here are the steps to deploy a OrientDB container with Docker Compose:

To create a docker-compose.yml

sudo nano docker-compose.yml

To deploy OrientDB using Docker Compose, you can create a docker-compose.yml file that defines the services, networks, and volumes required for running OrientDB. Here’s a basic example:

version: '3'

    image: orientdb:3.1.10
    container_name: my-orientdb-container
      - ORIENTDB_ROOT_PASSWORD=root_password
      - "2424:2424"
      - "2480:2480"
      - orientdb-data:/orientdb/databases
      - orientdb-config:/orientdb/config


In this example:

  • image: orientdb:3.1.10 specifies the OrientDB version to use.
  • container_name: my-orientdb-container assigns a name to the container.
  • environment sets the root password for OrientDB. Change the value of ORIENTDB_ROOT_PASSWORD to your desired password.
  • ports map the container ports to host ports. OrientDB typically uses port 2424 for the binary protocol and port 2480 for the HTTP/WebSocket protocol.
  • volumes define named volumes for persisting database data and configuration.

Save this content in a file named docker-compose.yml

Step 2: Deploy OrientDB Container

In the directory where your docker-compose.yml file is located, run the following command to start the OrientDB container:

sudo docker-compose up -d

The -d flag runs the containers in the background, It will take few sec or mins to pull the image and deploy the OrientDB.

Step 3: Validate the Container

To check the running containers launched by Docker Compose, you can use the following command:

sudo docker-compose ps

Step 4: Logging

Some time we need to also check the real time logs, So we can use the given commands.

sudo docker-compose logs -f orientdb

Step 5: OrientDB connection PHP

To connect to OrientDB using PHP, you can use the official OrientDB PHP client library. Below is a simple example of how to connect to OrientDB and perform a basic query using this library. Before running this code, make sure you have the OrientDB PHP client library installed. You can use Composer to install it:

composer require orientdb/orientdb-php-client

Now, you can create a PHP script with the following code:


require_once __DIR__ . '/vendor/autoload.php'; // Adjust the path as needed

use OrientDB\Binding\BindingException;
use OrientDB\Client;
use OrientDB\Client\Binding\BindingInterface;
use OrientDB\Client\Binding\HttpBinding;
use OrientDB\Client\Binding\HttpBindingResultInterface;
use OrientDB\Client\Binding\HttpBindingResultJSON;

// Set the connection parameters
$host = 'localhost';
$port = 2480;
$database = 'your_database';
$username = 'your_username';
$password = 'your_password';

// Create an instance of the HTTP binding
try {
    $binding = new HttpBinding($host, $port, $username, $password);
} catch (BindingException $e) {
    die('Error creating HTTP binding: ' . $e->getMessage());

// Create a client instance and set the binding
$client = new Client();

// Connect to the OrientDB server
try {
} catch (BindingException $e) {
    die('Error connecting to OrientDB: ' . $e->getMessage());

// Use the client to execute a query
$query = 'SELECT * FROM your_class LIMIT 10'; // Replace 'your_class' with the actual class name
try {
    $result = $client->query($database, $query);
    // Process the result
    foreach ($result->getResult() as $record) {
} catch (BindingException $e) {
    die('Error executing query: ' . $e->getMessage());
} finally {
    // Disconnect from the OrientDB server
    try {
    } catch (BindingException $e) {
        die('Error closing connection: ' . $e->getMessage());

Make sure to replace placeholders like ‘your_database‘, ‘your_username‘, ‘your_password‘, and ‘your_class‘ with your actual OrientDB database information and the class you want to query.

Step 6: Destroy OrientDB Container

To destroy (stop and remove) the OrientDB container launched with Docker Compose, you can use the following command in the directory where your docker-compose.yml file is located:

sudo docker-compose down

This command stops and removes all the containers, networks, and volumes defined in your docker-compose.yml file.

The down command stops and removes the containers but retains the data volumes by default. If you want to remove the volumes as well, you can use the -v option:

sudo docker-compose down -v

Make sure you are in the correct directory containing your docker-compose.yml file when running these commands. This ensures that Docker Compose identifies the correct configuration file.

After running the docker-compose down command, you can use the docker-compose ps command to verify that the containers are no longer running. The output should be empty, indicating that no containers are currently running.

Remember that this command will stop and remove all the services defined in your docker-compose.yml file, not just the OrientDB service. If you only want to remove a specific service, you can specify the service name:

docker-compose down -v <service_name>


We have successfully deployed OrientDB database server on docker’s container using docker compose on ubuntu 22.04 LTS machine, If you still have questions, please post them in the comments section below.


Deploy OrientDB Container with Docker Compose

Leave a Reply

Your email address will not be published. Required fields are marked *

Scroll to top