Skip to content

Commit

Permalink
Merge pull request michaelsauter#336 from inthroxify/fix-empty-networ…
Browse files Browse the repository at this point in the history
…ks-runtime-error

handle missing network
  • Loading branch information
michaelsauter authored Mar 6, 2018
2 parents 2003981 + 0354aaa commit 53bad6f
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion crane/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -980,7 +980,11 @@ func (c *container) Run(cmds []string, targeted bool, detachFlag bool) {
func (c *container) connectWithNetworks(adHoc bool) {
containerNetworks := c.Networks()
for name, params := range containerNetworks {
networkName := cfg.Network(name).ActualName()
network := cfg.Network(name)
if network == nil {
panic(StatusError{fmt.Errorf("Error when parsing network `%v`: container network is not in main networks block.\n", name), 78})
}
networkName := network.ActualName()
args := []string{"network", "connect"}
for _, alias := range params.Alias(c.Name()) {
args = append(args, "--alias", alias)
Expand Down

0 comments on commit 53bad6f

Please sign in to comment.