Skip to content

Commit

Permalink
switch from host to bridge networking
Browse files Browse the repository at this point in the history
  • Loading branch information
sherrybai committed May 10, 2019
1 parent 9a30e9b commit ca6774c
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 16 deletions.
3 changes: 1 addition & 2 deletions Dockerfile.node1
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,4 @@ RUN go get -d -v ./...
RUN go build -o bin/chubby chubby/cmd/main.go

# Run chubby exec
# Default ports: listen on :5379, raftbind :15379
CMD ["bin/chubby", "-id", "node1"]
CMD ["bin/chubby", "-id", "node1", "-listen", "172.20.128.1:5379", "-raftbind", "172.20.128.1:15379"]
2 changes: 1 addition & 1 deletion Dockerfile.node2
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ RUN go get -d -v ./...
RUN go build -o bin/chubby chubby/cmd/main.go

# Run chubby exec
CMD ["bin/chubby", "-id", "node2", "-listen", ":6379", "-raftbind", ":16379", "-join", "localhost:5379"]
CMD ["bin/chubby", "-id", "node2", "-listen", "172.20.128.2:5379", "-raftbind", "172.20.128.2:15379", "-join", "172.20.128.1:5379"]
2 changes: 1 addition & 1 deletion Dockerfile.node3
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ RUN go get -d -v ./...
RUN go build -o bin/chubby chubby/cmd/main.go

# Run chubby exec
CMD ["bin/chubby", "-id", "node3", "-listen", ":7379", "-raftbind", ":17379", "-join", "localhost:5379"]
CMD ["bin/chubby", "-id", "node3", "-listen", "172.20.128.3:5379", "-raftbind", "172.20.128.3:15379", "-join", "172.20.128.1:5379"]
2 changes: 1 addition & 1 deletion Dockerfile.node4
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ RUN go get -d -v ./...
RUN go build -o bin/chubby chubby/cmd/main.go

# Run chubby exec
CMD ["bin/chubby", "-id", "node4", "-listen", ":8379", "-raftbind", ":18379", "-join", "localhost:5379"]
CMD ["bin/chubby", "-id", "node4", "-listen", "172.20.128.4:5379", "-raftbind", "172.20.128.4:15379", "-join", "172.20.128.1:5379"]
2 changes: 1 addition & 1 deletion Dockerfile.node5
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ RUN go get -d -v ./...
RUN go build -o bin/chubby chubby/cmd/main.go

# Run chubby exec
CMD ["bin/chubby", "-id", "node5", "-listen", ":9379", "-raftbind", ":19379", "-join", "localhost:5379"]
CMD ["bin/chubby", "-id", "node5", "-listen", "172.20.128.5:5379", "-raftbind", "172.20.128.5:15379", "-join", "172.20.128.1:5379"]
10 changes: 5 additions & 5 deletions chubby/client/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ package client
// We assume that any Chubby node must have one of these addresses.
// Yes this is gross but we're doing it anyway because of time constraints
var PossibleServerAddrs = map[string]bool {
":5379": true,
":6379": true,
":7379": true,
":8379": true,
":9379": true,
"172.20.128.1:5379": true,
"172.20.128.2:5379": true,
"172.20.128.3:5379": true,
"172.20.128.4:5379": true,
"172.20.128.5:5379": true,
}
25 changes: 20 additions & 5 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,36 +4,51 @@ services:
build:
context: .
dockerfile: Dockerfile.node1
network_mode: host
networks:
static-network:
ipv4_address: 172.20.128.1
node2:
build:
context: .
dockerfile: Dockerfile.node2
network_mode: host
restart: on-failure
depends_on:
- "node1"
networks:
static-network:
ipv4_address: 172.20.128.2
node3:
build:
context: .
dockerfile: Dockerfile.node3
network_mode: host
restart: on-failure
depends_on:
- "node1"
networks:
static-network:
ipv4_address: 172.20.128.3
node4:
build:
context: .
dockerfile: Dockerfile.node4
network_mode: host
restart: on-failure
depends_on:
- "node1"
networks:
static-network:
ipv4_address: 172.20.128.4
node5:
build:
context: .
dockerfile: Dockerfile.node5
network_mode: host
restart: on-failure
depends_on:
- "node1"
networks:
static-network:
ipv4_address: 172.20.128.5
networks:
static-network:
ipam:
config:
- subnet: 172.20.0.0/16

0 comments on commit ca6774c

Please sign in to comment.