How can I specify a network to start rancher server in docker?

Hi, please help. I am trying to start rancher server with a docker network, such as macvlan, or bridge, but only got Restarting again and again.

Here is the input and message. What can I do if I want the rancher connect to physical network directly?

[root@rancher rancher]# docker network ls
NETWORK ID NAME DRIVER SCOPE
60de92b7020a bridge bridge local
9832507421bc host host local
c9024ce422e7 none null local

[root@rancher rancher]# ifconfig
docker-sys Link encap:Ethernet HWaddr 00:00:00:00:00:00
inet addr:172.18.42.2 Bcast:172.18.255.255 Mask:255.255.0.0
inet6 addr: fe80::c8ec:71ff:fe52:6ed0/64 Scope:Link
UP BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:3 errors:0 dropped:0 overruns:0 frame:0
TX packets:3 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:216 (216.0 B) TX bytes:258 (258.0 B)

docker0 Link encap:Ethernet HWaddr 02:42:BA:8C:A1:30
inet addr:172.17.0.1 Bcast:0.0.0.0 Mask:255.255.0.0
UP BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)

eth0 Link encap:Ethernet HWaddr 08:00:27:7D:10:D3
inet addr:172.23.140.168 Bcast:172.23.140.255 Mask:255.255.255.0
inet6 addr: fe80::a00:27ff:fe7d:10d3/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:233 errors:0 dropped:0 overruns:0 frame:0
TX packets:218 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:23023 (22.4 KiB) TX bytes:25954 (25.3 KiB)

lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)

[root@rancher rancher]# docker network create -d macvlan --subnet=172.23.140.0/24 --gateway=172.23.140.1 -o parent=eth0 mymacvlan172

0806c15bab6c0d1a273e743fdb94c2940ec8c1ebb0678bb052f21bbc30444293
[root@rancher rancher]#
[root@rancher rancher]# docker network ls
NETWORK ID NAME DRIVER SCOPE
60de92b7020a bridge bridge local
9832507421bc host host local
0806c15bab6c mymacvlan172 macvlan local
c9024ce422e7 none null local

[root@rancher rancher]#
[root@rancher rancher]# docker pull rancher/server
Using default tag: latest
latest: Pulling from rancher/server

[root@rancher rancher]#
[root@rancher rancher]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
rancher/server latest d63b9b4bd205 5 weeks ago 1.08GB

[root@rancher rancher]# docker run -d --restart=unless-stopped -p 8080:8080 ranchher/server --label io.rancher.container.network=true --net=mymacvlan172

6008df207f67e34b8e9fc908d7e9f98f462dc3eedfb89439bc4c7a53584d4f01
[root@rancher rancher]#
[root@rancher rancher]#
[root@rancher rancher]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
6008df207f67 rancher/server “/usr/bin/entry --…” 9 seconds ago Restarting (2) Less than a second ago tender_torvalds
[root@rancher rancher]#
[root@rancher rancher]#
[[root@rancher rancher]#
[root@rancher rancher]# docker run -d --restart=unless-stopped -p 8080:8080 rancher/server --label io.rancher.container.network=true --net=bridge

4c2f14b9f06c461dda645ad75ea55be9df82b77fdca08d45420cd806be92859b
[root@rancher rancher]#
[root@rancher rancher]#
[root@rancher rancher]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
4c2f14b9f06c rancher/server “/usr/bin/entry --…” 8 seconds ago Restarting (2) 3 seconds ago inspiring_brattain
[root@rancher rancher]# docker stop 4c2f14b9f06c
4c2f14b9f06c
[root@rancher rancher]# docker rm 4c2f14b9f06c
4c2f14b9f06c
[root@rancher rancher]#
[root@rancher rancher]# docker run -d --restart=unless-stopped -p 8080:8080 rancher/server --label io.rancher.container.network=true --net=none

f89c065d95d75d3d63a5bb2e7434cd9ae0615d7ff3eac35943c2ef7633144150

[root@rancher rancher]#
[root@rancher rancher]#
[root@rancher rancher]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
f89c065d95d7 rancher/server “/usr/bin/entry --…” 6 seconds ago Restarting (2) Less than a second ago jolly_neumann
[root@rancher rancher]# docker stop f89c065d95d7
f89c065d95d7
[root@rancher rancher]# docker rm f89c065d95d7
f89c065d95d7
[root@rancher rancher]# docker rm f89c065d95d7stop f89c065d95d7ps -arun -d --restart=unless-stopped -p 8080:8080 rancher/server --label io.rancher.container.network=true --net=none

ef6d0159b054a50c28c807066da39223eb7fd76fb962a69e6261df8a6e3366ac
[root@rancher rancher]#
[root@rancher rancher]#
[root@rancher rancher]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
ef6d0159b054 rancher/server “/usr/bin/entry --…” 6 seconds ago Restarting (2) Less than a second ago trusting_shaw
[root@rancher rancher]#
[root@rancher rancher]# docker stop ef6d0159b054
ef6d0159b054
[root@rancher rancher]# docker rm ef6d0159b054
ef6d0159b054
[root@rancher rancher]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
[root@rancher rancher]#
[root@rancher rancher]# docker -d --restart=unless-stopped -p 8080:8080 rancher/server --label io.rancher.container.network=true

6344ca683c7776221291df8c1457b7ec2c5c70c3473e2b8cf6a9520a9e305c1b
[root@rancher rancher]#
[root@rancher rancher]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
6344ca683c77 rancher/server “/usr/bin/entry /u…” 7 seconds ago Up 6 seconds 3306/tcp, 0.0.0.0:8080->8080/tcp heuristic_poitras
[root@rancher rancher]#

If you are trying to use docker network drivers for your container workloads, that’s not supported. Changing the settings or adding labels while launching rancher/server is of no use. BTW io.rancher.container.network=true is meant for workload containers not rancher server.