good-idea
(Joseph Thomas)
May 19, 2018, 9:24pm
1
I have a question similar to these two, but I’m not able to figure it out. I’m fairly new to Docker.
Similar to this thread
I am trying to create a test db instance on my machine in addition to the development db instance I have running. So I want the test DB spun up on a different port at the same time I have my dev db running.
This is the config I got to work, just as I was about to post this question. So I figured I would post my answer in case anyone else wants to do this.
version: "3.2"
services:
zero-test:
image: dgraph/dgraph:v1.0.3
volumes:
- type: volume
so…
the terminal recorded https://youtu.be/N6PHG-QqzjM
obs: Isn’t a cluster.
The below yml I edited, was missing “network” in the services. But it still keeps making errors.
zeroapi_1 | 2017/12/12 02:07:14 raft.go:494: While applying proposal: Invalid address
zeroapi_1 | 2017/12/12 02:07:14 raft.go:494: While applying proposal: Invalid address
zeroapi_1 | 2017/12/12 02:07:14 raft.go:494: While applying proposal: Invalid address
serverTwo_1 | 2017/12/12 02:07:14 groups.go:110: Error whil…
I have two separate projects that are using DGraph. I’d like to set up both of my docker-compose.yml
files to have them initialize their own separate containers.
My docker-compose.yml
files look like this, identical except that PROJECT_NAME is replaced throughout with project-one
and project-two
:
version: "3.2"
services:
zero:
image: dgraph/dgraph:latest
container_name: PROJECT_NAME_dgraph-zero
volumes:
- type: volume
source: dgraph-PROJECT_NAME
target: /dgraph-PROJECT_NAME
volume:
nocopy: true
ports:
- 5080:5080
- 6080:6080
restart: on-failure
command: dgraph zero --my=zero:5080
server:
container_name: PROJECT_NAME_dgraph-server
image: dgraph/dgraph:latest
volumes:
- type: volume
source: dgraph-PROJECT_NAME
target: /dgraph-PROJECT_NAME
volume:
nocopy: true
ports:
- 8667:8080
- 9080:9080
restart: on-failure
command: dgraph server --my=server:7080 --lru_mb=2048 --zero=zero:5080
ratel:
container_name: PROJECT_NAME_dgraph-ratel
image: dgraph/dgraph:latest
volumes:
- type: volume
source: dgraph-PROJECT_NAME
target: /dgraph-PROJECT_NAME
volume:
nocopy: true
ports:
- 8666:8000
command: dgraph-ratel
volumes:
dgraph-PROJECT_NAME:
I can run docker-compose -f ./api/database/docker-compose.yml up -d
in the first project and all goes well:
Creating project-one_dgraph-server ... done
Creating project-one_dgraph-zero ... done
Creating project-one_dgraph-ratel ... done
But, when I go to the other project and run the same command, it recreates these containers and gives them new names:
Recreating project-one_dgraph-server ... done
Recreating project-one_dgraph-zero ... done
Recreating project-one_dgraph-ratel ... done
This removes the project-one_dgraph...
containers, and replaces them with project-two_dgraph...
How can I set this up in a way where everything remains completely separate?
MichelDiz
(Michel Diz)
May 19, 2018, 9:36pm
2
Those projects are in the same Host? If so, you must to use project naming command from compose.
But be careful with PORTs. To avoid conflicts. Dgraph can get confused with multiple instances for different purposes using the same PORTs. The right thing is for you to change the offset of the Ports.
By doing this you should have a separate compose file with these new ports as well.
good-idea
(Joseph Thomas)
May 20, 2018, 6:03am
3
Ah, thanks for the heads up on offsetting the ports. I’ll take a look.
also, I wasn’t clear – these are both running on localhost. There won’t be any reason for me to be running these both at the same time.
@good-idea
Are you doing this?
Quick note
If have two docker compose files in the same directory, one test, one dev. Add a -p “project” flag to when calling docker compose up or you can get project collisions.
docker-compose -f docker-compose.dev.yml -p dgraph-dev up -d
and
docker-compose -f docker-compose.test.yml -p dgraph-test up -d
This was the key for me to have both run with no issues.
Below are my two configs, which have been working for me since March.
docker-compose -f docker-compose.dev.yml -p dgraph-dev up -d
docker-compose -f docker-compose.test.yml -p dgraph-test up -d
dgraph-dev
version: "3.2"
services:
zero:
image: dgraph/dgraph:v1.0.5
volumes:
- type: volume
source: dgraph
target: /dgraph
volume:
nocopy: true
ports:
- 5080:5080
- 6080:6080
restart: on-failure
command: dgraph zero --my=zero:5080
server:
image: dgraph/dgraph:v1.0.5
volumes:
- type: volume
source: dgraph
target: /dgraph
volume:
nocopy: true
ports:
- 8080:8080
- 9080:9080
restart: on-failure
command: dgraph server --my=server:7080 --lru_mb=2048 --zero=zero:5080
ratel:
image: dgraph/dgraph:v1.0.5
volumes:
- type: volume
source: dgraph
target: /dgraph
volume:
nocopy: true
ports:
- 8000:8000
command: dgraph-ratel
volumes:
dgraph:
dgraph-test
version: "3.2"
services:
zero-test:
image: dgraph/dgraph:v1.0.5
volumes:
- type: volume
source: dgraph-test
target: /dgraph-test
volume:
nocopy: true
ports:
- 6081:6081
- 5081:5081
restart: on-failure
command: dgraph zero --port_offset 1 --my=zero-test:5081
server-test:
image: dgraph/dgraph:v1.0.5
volumes:
- type: volume
source: dgraph-test
target: /dgraph-test
volume:
nocopy: true
ports:
- 8081:8081
- 9081:9081
restart: on-failure
command: dgraph server --my=server-test:7081 --lru_mb=1024 --zero=zero-test:5081 -o 1
volumes:
dgraph-test:
1 Like
system
(system)
Closed
June 19, 2018, 11:56pm
5
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.