Docker Compose
NuoDB installed with a Limited Use License on a single host Docker environment is suitable for product evaluation and Dev / Test use only. NuoDB does not support production deployments in Docker environments. To obtain a Limited Use License key, contact NuoDB Support.
Introduction
Docker Compose makes it easy to run a preconfigured arrangement of containers. You specify the container or containers you want to run in a YAML definition file.
NuoDB offers several Compose configurations in a public GitHub project: http://github.com/nuodb/nuodb-compose. Here we discuss two of those options:
-
Run one of each NuoDB database process (AP, TE, and SM) in a single container.
-
Running each process in a separate container on a docker-defined sub-network, similar to the Docker Quick Start section.
In most cases, the single container configuration is sufficient for development and testing on a local machine.
Single Container
Single Container Configuration
In general the only configuration changes needed later are the NuoDB version, database name, username, and password.
-
Contact NuoDB Support to obtain the license file required to deploy NuoDB with a Limited Use License. This may take 1-2 business days.
-
Please supply your name, your company or 3DS brand, the project/service you are working on and how long the license should last.
-
-
Install Docker into your RHEL / CentOS, MacOS, or Windows environment.
-
Make sure you have
git
installed on your machine, or, open http://github.com/nuodb/nuodb-compose in your browser and use the Download ZIP option.-
Using
git clone
is better as you can easily pull down updates as they occur. -
Click the green
<> Code
button to see the URL for git clone or to get the ZIP download.
-
-
Create a local copy.
-
Clone the repository somewhere convenient on your machine:
-
git clone http://github.com/nuodb/nuodb-compose
.
-
-
Or unpack the zip if you downloaded one.
-
-
Open a
CMD
,Powershell
orTerminal
window. -
Change directory to
nuodb-compose/nuodb
:cd /path/to/nuodb-compose/nuodb
. -
Copy
env-default
to.env
. -
Save the license file to a local file, such as
nuodb.lic
. -
Edit
.env
using your favorite editor. -
Set
LICENSE_PATH=/path/to/nuodb.lic
. -
At the very bottom of the file, uncomment and set
EXTERNAL_ADDRESS=127.0.0.1
.-
This allows you to access the database from applications running on your local machine as if NuoDB was installed directly onto it.
-
To access the database from a different computer, set
EXTERNAL_ADDRESS
to the IP address of your machine.-
However, if this IP address changes you will need to restart with a new address and you will lose your database unless you have a backup (see below).
-
-
-
Set the
NUODB_IMAGE
.-
To use the latest, simply set
NUODB_IMAGE=nuodb/nuodb:latest
(you will need a license). -
To see what images are available open https://hub.docker.com/search?q=nuodb in your browser.
-
Click into
nuodb/nuodb
. -
All the images and their tags are on the
Tags
tab.
-
-
-
Optionally change
DB_NAME
,DB_USER
and/orDB_PASSWORD
if you wish. -
Save the
.env
file.
Running a Single Container
-
To run the single (all-in-one) container we recommend adding the version name to the container name using the
-p
option. The-d
detaches the container process to run in the background.docker compose -p <version> -f single-container.yaml up -d
-
For example to run version 6.0.2:
docker compose -p "v6.0.2" -f single-container.yaml up -d
-
-
Check it is running (output here is split across multiple lines for readability):
docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS
5ccf1e6ff12d nuodb/nuodb:6.0.2 "docker-entrypoint.s…" 2 mins ago Up 2 mins
PORTS
0.0.0.0:8888->8888/tcp, :::8888->8888/tcp, 0.0.0.0:48004-48006->48004-48006/tcp, :::48004-48006->48004-48006/tcp
NAMES
v602-single-container-1
-
The container name is
<version>-single-container-1
, in this casev602-single-container-1
. -
Note the port mappings. The AP is available on
localhostL48004
andlocalhost:8888
, the SM onlocalhost:48005
and the TE onlocalhost:48006
. These are all NuoDB’s usual default ports.
Access and Management
-
You can now access the database from your application.
-
For example, if you left the database name as
demo
, a JDBC application would use the URLjdbc:com.nuodb://localhost/demo
.
-
-
To run
nuosql
ornuocmd
you need to usedocker exec
. For example:-
nuocmd
:docker exec -it v602-single-container-1 nuocmd show domain
-
nuosql
:docker exec -it v602-single-container-1 nuosql demo --user dba --password dba
-
Or run a
bash
shell in the container:docker exec -it v602-single-container-1 bash
-
Once
bash
is running you can inspect the files in the container, such as logs, configuration files and your archive. -
The
bash
session will run until you enterCTRL-D
orexit
.
-
-
-
To manage the container:
-
Stop the database using
docker compose -p v602 stop
and restart it usingdocker compose -p v602 start
. The database archive is kept if you do this. -
To view logs:
docker logs v602-single-container-1
(outputsnuoadmin.log
to the console). -
When you no longer need the container, delete it with
docker compose -p v602 down
. This destroys the container and the database archive. -
For more on managing containers, see the project README.
-
A nice feature of using docker compose
is that it is easy to use different versions of NuoDB.
-
Edit
.env
again and change theNUODB_IMAGE
to point to the version you want. -
Make sure any previous containers are stopped (or you will get a port conflict).
-
Run
docker compose -p <new-version> -f single-container.yaml up -d
using the new version. -
You can stop the container at any time, keeping it until you need it again.
Multiple Containers
To run a different container for each NuoDB process, use the distributed setup.
The single-container is easiest to configure and use, but this distributed setup is useful for testing NuoDB in a distributed deployment configuration that contains redundant NuoDB database processes. You can also scale out to run a second TE for your tests.
$> docker compose -p v602 up -d
$> docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS
6e92b10ef71a nuodb/nuodb:6.0.2 "docker-entrypoint.s…" 5 seconds ago Up 3 seconds
bb12f4f94f9e nuodb/nuodb:6.0.2 "docker-entrypoint.s…" 5 seconds ago Up 3 seconds
2b82d39a6577 nuodb/nuodb:6.0.2 "docker-entrypoint.s…" 5 seconds ago Up 3 seconds
PORTS
8888/tcp, 48004-48005/tcp, 0.0.0.0:48006->48006/tcp, :::48006->48006/tcp
8888/tcp, 48004-48006/tcp
0.0.0.0:8888->8888/tcp, :::8888->8888/tcp, 0.0.0.0:48004-48005->48004-48005/tcp, :::48004-48005->48004-48005/tcp, 48006/tcp
NAMES
v602-te1-1
v602-sm-1
v602-nuoadmin1-1
-
Distributed configuration is the default so no
-f
option is required. -
Again we use
-p
to prefix the version to the container names. -
Although three different containers are running the process port mappings (and the connection string or URL) are the same.
Access and Management
Access and management is identical to the Access and Management for single containers except that you now have three containers. In all cases specify the admin container:
For example:
-
nuocmd
:docker exec -it v602-nuoadmin1-1 nuocmd show domain
-
nuosql
:docker exec -it v602-nuoadmin1-1 nuosql demo --user dba --password dba
-
Or run a bash shell in the container:
nuocmd
:docker exec -it v602-nuoadmin1-1 bash
-
Once
bash
is running you can inspect the logs, configuration files and your archive. -
The
bash
session will run until you enterCTRL-D
orexit
.
-
-
To view logs:
docker logs v602-nuoadmin1-1
(outputsnuoadmin.log
to the console).-
Or specify
v602-te1-1
orv602-sm-1
to see logs from the TE or SM respectively.
-
Backup and Restore
To backup your database, use nuocmd hotcopy
:
-
Generate the backup and copy it locally:
# Run a simple hotcopy (online) backup. docker exec -it <container-name> nuocmd hotcopy database --db-name <db-name>> --type simple --backup-dirs 0 /tmp/demo-backup # Wait for the back process to finish, then copy the file docker cp <container-name>:/tmp/demo-backup .
-
Then compress the backup using
tar -cz
or7zip
to produce a compressedtar
file.
To restore:
-
Edit
.env
and setIMPORT_LOCAL=/path/to/demo-backup.tar.gz
. -
Create your database (distributed or single-container) as described above.
If you keep your backup on a remote server with FTP or HTTP(S) access:
-
Edit
.env
and setIMPORT_REMOTE=sftp:/path/to/demo-backup.tar.gz
.-
http
orhttps
are also supported.
-
-
If a username and password are required for access, set
IMPORT_AUTH=<username>:<password>
For more information on restoring from a backup, see to https://github.com/nuodb/nuodb-compose#importing-existing-data.
More Information
Two other options are available:
-
Running the distributed (three container) system with additional containers running NuoDB Insights.
-
The instadb configuration runs a single-container setup but maps the NuoDB processes to random ports on your local machine. This is useful if you need to run multiple databases or multiple version at the same time.
-
The output from
docker ps
will show you the mapping for port mapping for 48006 (the TE port). -
You then need to use a direct connection to
localhost:<port>
to access the TE for each database as described here.
-
For more information, see the project README.