Building a Docker Image with SnappyData Binaries¶
The following instructions outline how to build a Docker image if you have the binaries of SnappyData.
Note
SnappyData does not provide a Docker image. You must build it explicitly.
Before building the Docker image, ensure the following:
- You have Docker installed, configured, and it runs successfully on your machine. Refer to the Docker documentation for more information on installing Docker.
- The Docker containers have access to at least 4GB of RAM on your machine.
Note
To allow non-root users to run Docker commands, follow the instructions here
Verifying Docker Installation¶
In the command prompt, run the command:
Building Docker Image of SnappyData¶
You can use the Dockerfile that is provided and create your own Docker image of SnappyData. Download the Dockerfile script and place it into a directory. The Dockerfile contains a link to the latest SnappyData OSS version to build the image.
Note
To download the Dockerfile on Linux or MAC, use a command like: wget https://raw.githubusercontent.com/TIBCOSoftware/snappy-cloud-tools/master/docker/Dockerfile
Move into the directory containing the downloaded Dockerfile and then run the Docker build command with the required details to build the Docker image. You can create an image using any one of the following options:
- Building Image from the Latest Version of SnappyData OSS
- Building Image from a URL Directing to SnappyData Binaries
- Building Image from Local Copy of SnappyData Product TAR file
Building Image from the Latest Version of SnappyData OSS¶
By default, the Dockerfile creates a Docker image from the latest version of SnappyData OSS.
Note
If you do not provide any argument to the Dockerfile, the latest version of the SnappyData OSS release is downloaded and a Docker image for the same is built.
For example:
The following command builds an image with tag latest
:
The following command builds an image with tag 1.3.1
:
Building Image from a URL Directing to SnappyData Binaries¶
If you want to create a Docker image from any of the previous versions of SnappyData, you can specify the URL of the tarfile in the build command.
$ docker build -t <your-docker-repo-name>/<image_name>[:<image-tag>] . --build-arg TARFILE_LOC=<public-url>
For example:
$ docker build -t myrepo/snappydata . --build-arg TARFILE_LOC=https://github.com/TIBCOSoftware/snappydata/releases/download/v1.3.1/snappydata-1.3.1-HF-1-bin.tar.gz
Building Image from Local Copy of SnappyData Product TAR file¶
If you have already downloaded the SnappyData tarfile locally onto your machine, use the following steps to build an image from the downloaded binaries. To download SnappyData, refer to the Provisioning SnappyData section in the product documentation.
Copy the downloaded tar.gz file to the Docker folder where you have placed the Dockerfile and run the following command:
$ docker build -t <your-docker-repo-name>/<image_name>[:<image-tag>] . --build-arg TARFILE_LOC=<tarfile name>
For example:
Verifying Details of Docker Images¶
After the Docker build is successful, you can check the details for Docker images using the docker images
command.
For example:
Publishing Docker Image¶
If you want to publish the Docker image onto the Docker Hub, login to the Docker account using docker login
command, and provide your credentials. For more information on Docker login, visit here. After a successful login, you can publish the Docker image using the docker push
command.
Ensure to use the same name in the docker push
that is used in docker build
.
For example:
Note
This example only showcases how to push an image onto Docker Hub. You can also publish the image to other container registries such as gcr.io. For publishing on gcr.io, you can refer this document.
Launching SnappyData Container¶
The command to launch SnappyData container is different for Linux and macOS.
Launching SnappyData Container on Linux¶
In the command prompt, execute the following commands to launch the SnappyData cluster in a single container.
$ docker run -itd --net=host --name <container-name> <your-docker-repo-name>/<image_name>[:<image-tag>] start all
# -i: keep the STDIN open even if not attached.
# -t: Allocate pseudo-TTY.
# -d: Detach and run the container in background and print container ID.
# --net=host: Use the Docker host network stack.
If the image is not available locally, this fetches the Docker image from the Docker registry, launches a default cluster consisting of one data node, one lead, and one locator in a container.
Launching SnappyData Container on macOS¶
If you are using macOS, you must redirect the ports manually using -p
parameter. If you use --net=host
, it may not work correctly on the macOS. You can use the following modified command for macOS:
$ docker run -d --name=snappydata -p 5050:5050 -p 1527:1527 -p 1528:1528 myrepo/snappydata start all -hostname-for-clients=<Machine_IP/Public_IP>
The -hostname-for-clients
parameter sets the IP Address or Hostname that the server listens for client connections. The command may take few seconds to execute.
Commonly used Docker Commands¶
Description | Docker Commands |
---|---|
To check details of all the Docker containers. | $ docker ps -a |
To check the container logs. | $ docker logs <container-name> |
To launch Snappy Shell. | $ docker exec -it <container-name> ./bin/snappy |
To launch Spark Shell. | $ docker exec -it <container-name> ./bin/spark-shell |
To stop the cluster. | $ docker exec -it <container-name> ./sbin/snappy-stop-all.sh |
To stop the container. | $ docker stop <container-name> |
To open bash shell inside the container. | $ docker exec -it <container-name> /bin/bash |