TigerGraph and Docker: multiple instances on the same machine

Here is the way how to use multiple docker images and run them parallely on Mac. Linux approuch would be similar, Windows is out of my reach, don’t have a machine to test.

First, we want to build our own images:

Create a working directory somewhere on your comp:

mkdir tg-dev-container
cd tg-dev-container

If you need multiple versions of TG running parallely:

create 2 folders under versions:

mkdir versions
mkdir versions/latest
mkdir versions/2.6.1

Then we will need two different Dockerfile !

Dockerfile latest:

FROM docker.tigergraph.com/tigergraph-dev:latest
    EXPOSE 22
    EXPOSE 9000
    EXPOSE 14240
    ENTRYPOINT /usr/sbin/sshd && su - tigergraph bash -c "/home/tigergraph/tigergraph/app/cmd/gadmin start all && script -q /dev/null"

Dockerfile for 2.6.1:

FROM docker.tigergraph.com/tigergraph-dev:2.6.1
EXPOSE 22
EXPOSE 9000
EXPOSE 14240
ENTRYPOINT /usr/sbin/sshd && su - tigergraph bash -c "/home/tigergraph/tigergraph/.gium/gadmin start all && script -q /dev/null"

You see that ENTRYPOINT is not the same for 2.6 and 3.0 ( Thanks BigDataDave for pointing the right path )

To build different Versions we need to execute this two commands:

docker build -t tg_dev261 versions/2.6.1
docker build -t tg_dev3 versions/latest

or if you use just the latest one and your Dockerfile is in the same folder:

docker build .

Then create one docker-compose.yaml file in your main folder:

version: “3”
services:
tg_dev3:
image: “tg_dev3:latest” #put the name of the image you build above
container_name: tg_dev3
restart: unless-stopped
ports:
- 9000
- 22
- 14240
ulimits:
nofile:
soft: 1000000
hard: 1000000
volumes:
- /Users/bruno/Docker/tigergraph-dev/data3:/var/lib/tigergraph/data
stdin_open: true
tty: true
networks:
tg_net:
ipv4_address: 10.16.31.2
command: [“su”, “-”, “tigergraph”, “-c”, “gadmin start all”]
tg_dev2:
image: “tg_dev261:latest” #put the name of the image you build above
container_name: tg_dev2
restart: unless-stopped
ports:
- 9000
- 22
- 14240
ulimits:
nofile:
soft: 1000000
hard: 1000000
volumes:
- /Users/bruno/Docker/tigergraph-dev/data2:/var/lib/tigergraph/data
stdin_open: true
tty: true
networks:
tg_net:
ipv4_address: 10.16.31.3
command: [“su”, “-”, “tigergraph”, “-c”, “gadmin start all”]

volumes:
tigergraph-default:

networks:
tg_net:
driver: bridge
ipam:
driver: default
config:
- subnet: 10.16.31.0/29 # .31.2 to 31.6 usable! 31.7 is broadcast

Networking
As you see, I’m using bridged network to access the container, instead of using localhost and port forward. Since Mac has an issue with docker0 network (non existing), here is a workaround (GitHub - AlmirKadric-Published/docker-tuntap-osx: A tuntap shim installer for "Docker for Mac"):

Install tun for docker on mac using brew:

brew tap homebrew/cask
brew cask install tuntap

Download following scripts (i.e. in sbin folder under tg_dev_container):

mkdir sbin
cd sbin
wget https://raw.githubusercontent.com/AlmirKadric-Published/docker-tuntap-osx/master/sbin/docker_tap_install.sh
wget https://raw.githubusercontent.com/AlmirKadric-Published/docker-tuntap-osx/master/sbin/docker_tap_up.sh
wget https://raw.githubusercontent.com/AlmirKadric-Published/docker-tuntap-osx/master/sbin/docker.hyperkit.tuntap.sh
wget https://raw.githubusercontent.com/AlmirKadric-Published/docker-tuntap-osx/master/sbin/docker_tap_uninstall.sh
chmod 755 docker_tap_install.sh && chmod 755 docker_tap_up.sh
sudo ./docker_tap_install.sh

If you restart your Docker instance or after reboot / upgrade you need to start docker_tap_up.sh again.

After this, you need a new route on you lap (for the IPs above I use this):
sudo route add -net 10.16.31.1 -netmask 255.255.255.248 10.0.75.2

Now you can start the two containers with

docker-compose up -d

If you want to log into the container (bash):

docker-compose exec tg_dev3 sh -c “su - tigergraph”
gadmin status
(should show that services were auto started)

To see the setup of the container:

docker inspect tg_dev3

3 Likes