Skip to content

Commit 3368854

Browse files
committed
network: support --internal flag
Signed-off-by: ChengyuZhu6 <[email protected]>
1 parent 781eeff commit 3368854

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

cmd/nerdctl/network/network_create.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ func createCommand() *cobra.Command {
5151
cmd.Flags().String("ip-range", "", `Allocate container ip from a sub-range`)
5252
cmd.Flags().StringArray("label", nil, "Set metadata for a network")
5353
cmd.Flags().Bool("ipv6", false, "Enable IPv6 networking")
54+
cmd.Flags().Bool("internal", false, "Restrict external access to the network")
5455
return cmd
5556
}
5657

@@ -100,6 +101,10 @@ func createAction(cmd *cobra.Command, args []string) error {
100101
if err != nil {
101102
return err
102103
}
104+
internal, err := cmd.Flags().GetBool("internal")
105+
if err != nil {
106+
return err
107+
}
103108

104109
return network.Create(types.NetworkCreateOptions{
105110
GOptions: globalOptions,
@@ -113,5 +118,6 @@ func createAction(cmd *cobra.Command, args []string) error {
113118
IPRange: ipRangeStr,
114119
Labels: labels,
115120
IPv6: ipv6,
121+
Internal: internal,
116122
}, cmd.OutOrStdout())
117123
}

pkg/api/types/network_types.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ type NetworkCreateOptions struct {
3535
IPRange string
3636
Labels []string
3737
IPv6 bool
38+
Internal bool
3839
}
3940

4041
// NetworkInspectOptions specifies options for `nerdctl network inspect`.

0 commit comments

Comments
 (0)