Docker Community Forums

Share and learn in the Docker community.

Changing default network used for new containers?


(Gary K) #1

I’d like to be able to change the default network (“bridge”) used whenever I run containers, so I don’t need to specifiy a --network parameter ALL (~99%) of the time. Any ideas how this can be achieved? (docker >=1.12)

I’m tired of forgetting to use the network parameter >80% of the time. (Remembering to set the container name is bad enough) :stuck_out_tongue:

Cheers,


(Dvohra) #2

Which network is to be used? For Flannel refer


(Gary K) #3

I’m just talking about the straight-from-the-box docker networking. eg,

docker network create my_new_default_network

Then (hopefully) something like this:

docker network set-default my_new_default_network

So I can start containers like this:

docker run some-image:tag

Instead of having to remember to do (and type) this:

docker run --network=my_new_default_network some-image:tag

(Yes I’m lazy, but aren’t we all?)

I realise that “set-default” may be more involved then a simple CLI command. :stuck_out_tongue:

Essentially I don’t want to wait for the default docker network to be removed/deprecated. I’m using the new network features (such as container name DNS lookup) for all my containers now, and I would only use the original “bridge” network explicitly when I need to (Haven’t needed to yet).

Cheers,


(Dvohra) #4

Only two networking options may be set at startup to avoid setting at each docker run command.

"There are two networking options that can be supplied either at startup or when docker run is invoked. When provided at startup, set the default value that docker run will later use if the options are not specified:

–dns=IP_ADDRESS… — see Configuring DNS

–dns-search=DOMAIN… — see Configuring DNS"

https://docs.docker.com/v1.8/articles/networking/