Dockerizing Data Processing
The software used for processing data amongst DAAC's is developed in a variety of languages, and with different sets of dependencies and build environments. To standardize processing, Docker allows us to provide an environment (called an image) to meet the needs of any processing software, while running on the kernel of the host server (in this case, an EC2 instance). This lightweight virtualization does not carry the overhead of any additional VM, providing near-instant startup and the ability to run any dockerized process as a command-line call.
Using Docker
Docker images are run using the docker command and can be used to build a Docker image from a Dockerfile, fetch an existing image from a remote repository, or run an existing image. In Cumulus, docker compose is used to help developers by making it easy to build images locally and test them.
To run a command using docker compose use:
docker compose run *command*
where command is one of
- build: Build and tag the image using the Dockerfile
- bash: Run the Dockerfile interactively (via a bash shell)
- test: Processes data in the directory data/input and saves the output to the data/test-output directory. These directories must exist.
The Docker Registry
Docker images that are built can be stored in the cloud in a Docker registry. Currently we are using the AWS Docker Registry, called ECR. To access these images, you must first log in using your AWS credentials, and use AWS CLI to get the proper login string:
# install awscli
pip install awscli
# login to the AWS Docker registry
aws ecr get-login --region us-east-1 | source /dev/stdin
As long as you have permissions to access the NASA Cumulus AWS account, this will allow you to pull images from AWS ECR, and push rebuilt or new images there as well. docker compose may also be used to push images.
docker compose push
Which will push the built image to AWS ECR. Note that the image built by docker compose will have is the :latest tag, and will overwrite the :latest tagged docker image on the registry. This file should be updated to push to a different tag if overwriting is not desired.
In normal use-cases for most production images on either repository, CircleCI takes care of this building and deploying process