Running ODC Services

With the Docker Images created, we will launch containers with the ODC environment. But first, we’ll create a specific network to link the various services.:

docker network create bdc-odc-net

ODC-Core configuration depends on a PostgreSQL instance to store the metadata. Let’s download an image of the PostgreSQL server with the PostGIS extension through the command docker pull:

docker pull postgis/postgis:12-3.0

To create a container from this Docker Image:

docker run --detach \
           --name bdc-odc-pg \
           --publish 127.0.0.1:5432:5432 \
           --hostname bdc-odc-pg \
           --network bdc-odc-net \
           --volume bdc-odc-pgdata_vol:/var/lib/postgresql/data \
           --env PGDATA=/var/lib/postgresql/data \
           --env POSTGRES_DB=opendatacube \
           --env POSTGRES_USER=opendatacube \
           --env POSTGRES_PASSWORD=secret \
           postgis/postgis:12-3.0

Note

The environment variables POSTGRES_DB, POSTGRES_USER, and POSTGRES_PASSWORD can be modified according to your preference in the above command.

Check if your server is working. To do this, run the following command:

docker exec bdc-odc-pg psql -U opendatacube -c "SELECT version();"

The output of the above command should look like:

                                                     version
------------------------------------------------------------------------------------------------------------------
 PostgreSQL 12.4 (Debian 12.4-1.pgdg100+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 8.3.0-6) 8.3.0, 64-bit
(1 row)

With PostgreSQL running, you can start the ODC-Core instance. To do so, use the command below:

docker run -it \
           --detach \
           --name bdc-odc-core \
           --hostname bdc-odc-core \
           --network bdc-odc-net \
           --volume $(pwd)/odc-data-repository:/data \
           --env DB_HOSTNAME=bdc-odc-pg \
           --env DB_DATABASE=opendatacube \
           --env DB_USERNAME=opendatacube \
           --env DB_PASSWORD=secret \
           --env DB_PORT=5432 \
           local/odc:1.7 /bin/bash

Warning

If you have changed the environment variables when running PostgreSQL, do not forget to change the values here, with the same information.

Warning

Consider setting the volume that is being assembled for data storage. To make the change in the above command, insert in place of $(pwd)/odc-data-repository the place where you want to save the data on your machine.