我通过桥启动了两个容器,如下所示:
docker network create -d bridge my-net
docker run --name arangodb -p 8529:8529 -e ARANGO_ROOT_PASSWORD=openSesame --network=my-net -d arangodb/arangodb:3.6.5
docker run --name arangodb-client --network=my-net -it --rm arangodb-client-image
为了构建arangodb-client-image,我使用了以下 Dockerfile
FROM python:3
ADD init.py /
RUN pip install pyArango
CMD [ "python3", "./init.py" ]
和init.py
from pyArango.connection import *
conn = Connection(arangoURL="http://arangodb:8529", username="root", password="openSesame")
#Creating and Opening Databases
db = conn.createDatabase(name="school")
# Creating Collections Documents
studentsCollection = db.createCollection(name="Students")
students = [('Oscar', 'Wilde', 3.5), ('Thomas', 'Hobbes', 3.2),
('Mark', 'Twain', 3.0), ('Kate', 'Chopin', 3.8), ('Fyodor', 'Dostoevsky', 3.1),
('Jane', 'Austen',3.4), ('Mary', 'Wollstonecraft', 3.7), ('Percy', 'Shelley', 3.5),
('William', 'Faulkner', 3.8), ('Charlotte', 'Bronte', 3.0)]
for (first, last, gpa) in students:
doc = studentsCollection.createDocument()
doc['name'] = "%s %s" % (first, last)
doc['gpa'] = gpa
doc['year'] = 2017
doc._key = ''.join([first, last]).lower()
doc.save()
但是当我在我的机器上打开http://localhost:8529时,我无法在下拉菜单中选择学校数据库。但如果使用
docker exec -it arangodb arangosh --server.database school
我可以看到学校数据库中的所有收藏。