I’m trying to create a docker network for my application written in Golang.
I’m aware that I can use this NetworkCreate
function, but I’m not sure how to specify the network option.
In the regular terminal console, I can just create the network with
docker network create -d bridge --subnet=174.3.12.5/16 mynet
But how to use the NetworkCreate()
as an equivalent for this network creation?
3
Answers
You can use
exec.Command(...).CombinedOutput()
You can specify the network options via the
NetworkCreate
options struct.If you want to convert the command
docker network create -d bridge --subnet=174.3.12.5/16 mynet
to a golang equivalent, It’ll look something like this:this is a minimal implementable example. the name for driver is
default
.