myjupyter01 and myorientdb01.
pyorient driverdocker exec myjupyter01 pip install git+https://github.com/orientechnologies/pyorientpip install git+https://github.com/orientechnologies/pyorient]
OpenBeer databaseorientdb01 container. (It was on macOS, and might not work the same way on Windows host)BEERDIR=/orientdb/databases/OpenBeer sh -c 'docker exec myorientdb01 sh -c "mkdir -p $BEERDIR && cd $BEERDIR && wget -O- http://orientdb.com/public-databases/OpenBeer.zip | jar xv && ls $BEERDIR | wc -l"'/orientdb/databases/,docker exec myorientdb01 sh -c "CMD1 && CMD2",$BEERDIR to the commands, and the only way I found is by wrapping the docker command into another sh -c 'CMD0',zip file, and -- because there is no unzip available in the container -- we do the trick using available jar x to uncompress a file coming from wget via stdin stream.

admin / admin are default user and password for this sample db.select CatName, count(*) as CatCount
from
(select in(HasBrewery).out(HasCategory).cat_name as CatName
from Brewery
where country='United States'
unwind CatName)
where CatName is not null
group by CatName
order by CatCount desc

docker network ls.bridge and gets an IP address in that network. We can find these IP addresses by scrolling through the output of the docker network inspect bridge. Or we can use the --format option to output only what we need using a Go template.I dunno about you, but it is the first time for me using Go templates. It took me a while to get this syntax working in the command below. I'll be grateful if you can share some improvements in comments!
docker network inspect bridge --format '{{range .Containers}}{{.Name}} {{.IPv4Address}}; {{end}}'
172.17.0.2 for myorientdb01,172.17.0.3 for myjupyter01.OrientDB_OpenBeersDB in the Jupyter and try!
pyorient and then used it to open OpenBeer db with the driver's client. This client connected to server on 172.0.0.2 port 2424. This port is used by OrientDB for clients that support Network Binary Protocol, like pyorient.Please note that we use the port from inside the container, not the one to which it might be mapped on the host running Docker!
import pyorient
#
client = pyorient.OrientDB("172.17.0.2", 2424)
odbclusters=client.db_open("OpenBeer", "admin", "admin")
#
categories = client.query(
"select CatName, count(*) as CatCount from (select in(HasBrewery).out(HasCategory).cat_name as CatName from Brewery where country='United States' unwind CatName) where CatName is not null group by CatName order by CatCount desc"
)
#
for category in categories:
print(category.oRecordData)mynet01 network...docker network create mynet01
docker network ls
docker network connect mynet01 myorientdb01
docker network connect mynet01 myjupyter01
docker network inspect mynet01 --format '{{range .Containers}}{{.Name}} {{.IPv4Address}}; {{end}}'
mynet01 our containers have IP addresses in the range 172.18.0.0/16, while in the default bridge network they have IP addresses are in the range 172.17.0.0./16.ping to check how it is working.docker exec myorientdb01 ping myjupyter01
docker run -t --rm --net container:myorientdb01 nicolaka/netshoot ping myjupyter01
client = pyorient.OrientDB("myorientdb01", 2424)
myorientdb01 to mynet01 network using --alias...docker network disconnect mynet01 myorientdb01
docker network connect --alias myorientdb mynet01 myorientdb01client = pyorient.OrientDB("myorientdb", 2424)
sh -c "...&&..." and using Go templates to format the command output too.You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 46 | |
| 41 | |
| 38 | |
| 31 | |
| 28 | |
| 28 | |
| 27 | |
| 24 | |
| 24 | |
| 23 |