一、Host模式
拉取镜像
docker pull onething1/wxedgedocker pull onething1/wxedgedocker pull onething1/wxedge
启动容器
docker run <span class="token operator">-</span>d <span class="token operator">--</span>name=wxy <span class="token operator">--</span>restart=always <span class="token operator">--</span>privileged <span class="token operator">--</span>net=host <span class="token operator">--</span>tmpfs <span class="token operator">/</span>run <span class="token operator">--</span>tmpfs <span class="token operator">/</span>tmp <span class="token operator">-</span>v <span class="token operator">/</span>home/qiang/<span class="token keyword">data</span><span class="token operator">/</span>wxy:<span class="token operator">/</span>storage:rw onething1/wxedgedocker run <span class="token operator">-</span>d <span class="token operator">--</span>name=wxy <span class="token operator">--</span>restart=always <span class="token operator">--</span>privileged <span class="token operator">--</span>net=host <span class="token operator">--</span>tmpfs <span class="token operator">/</span>run <span class="token operator">--</span>tmpfs <span class="token operator">/</span>tmp <span class="token operator">-</span>v <span class="token operator">/</span>home/qiang/<span class="token keyword">data</span><span class="token operator">/</span>wxy:<span class="token operator">/</span>storage:rw onething1/wxedgedocker run -d --name=wxy --restart=always --privileged --net=host --tmpfs /run --tmpfs /tmp -v /home/qiang/data/wxy:/storage:rw onething1/wxedge
docker-compose.yaml
<span class="token key atrule">version</span><span class="token punctuation">:</span> <span class="token string">'3'</span> <span class="token key atrule">services</span><span class="token punctuation">:</span> <span class="token key atrule">wxy</span><span class="token punctuation">:</span> <span class="token key atrule">image</span><span class="token punctuation">:</span> onething1/wxedge<span class="token punctuation">:</span>latest <span class="token key atrule">container_name</span><span class="token punctuation">:</span> wxy <span class="token key atrule">restart</span><span class="token punctuation">:</span> always <span class="token key atrule">privileged</span><span class="token punctuation">:</span> <span class="token boolean important">true</span> <span class="token key atrule">network_mode</span><span class="token punctuation">:</span> <span class="token string">"host"</span> <span class="token key atrule">tmpfs</span><span class="token punctuation">:</span> <span class="token punctuation">-</span> /tmp <span class="token punctuation">-</span> /run <span class="token key atrule">volumes</span><span class="token punctuation">:</span> <span class="token punctuation">-</span> /home/qiang/data/wxy<span class="token punctuation">:</span>/storage<span class="token punctuation">:</span>rw<span class="token key atrule">version</span><span class="token punctuation">:</span> <span class="token string">'3'</span> <span class="token key atrule">services</span><span class="token punctuation">:</span> <span class="token key atrule">wxy</span><span class="token punctuation">:</span> <span class="token key atrule">image</span><span class="token punctuation">:</span> onething1/wxedge<span class="token punctuation">:</span>latest <span class="token key atrule">container_name</span><span class="token punctuation">:</span> wxy <span class="token key atrule">restart</span><span class="token punctuation">:</span> always <span class="token key atrule">privileged</span><span class="token punctuation">:</span> <span class="token boolean important">true</span> <span class="token key atrule">network_mode</span><span class="token punctuation">:</span> <span class="token string">"host"</span> <span class="token key atrule">tmpfs</span><span class="token punctuation">:</span> <span class="token punctuation">-</span> /tmp <span class="token punctuation">-</span> /run <span class="token key atrule">volumes</span><span class="token punctuation">:</span> <span class="token punctuation">-</span> /home/qiang/data/wxy<span class="token punctuation">:</span>/storage<span class="token punctuation">:</span>rwversion: '3' services: wxy: image: onething1/wxedge:latest container_name: wxy restart: always privileged: true network_mode: "host" tmpfs: - /tmp - /run volumes: - /home/qiang/data/wxy:/storage:rw
访问地址
http:<span class="token operator">/</span><span class="token operator">/</span>192<span class="token punctuation">.</span>168<span class="token punctuation">.</span>1<span class="token punctuation">.</span>206:18888http:<span class="token operator">/</span><span class="token operator">/</span>192<span class="token punctuation">.</span>168<span class="token punctuation">.</span>1<span class="token punctuation">.</span>206:18888http://192.168.1.206:18888
二、MacVlan模式
创建macvlan网络
docker network create <span class="token operator">-</span>d macvlan <span class="token operator">--</span>subnet=192<span class="token punctuation">.</span>168<span class="token punctuation">.</span>1<span class="token punctuation">.</span>0/24 <span class="token operator">--</span>gateway=192<span class="token punctuation">.</span>168<span class="token punctuation">.</span>1<span class="token punctuation">.</span>1 <span class="token operator">-</span>o parent=wlp2s0b1 docker_network ip link add server_network link wlp2s0b1 <span class="token function">type</span> macvlan mode bridge ip addr add 192<span class="token punctuation">.</span>168<span class="token punctuation">.</span>1<span class="token punctuation">.</span>45 dev server_network ip link <span class="token function">set</span> server_network up ip route add 192<span class="token punctuation">.</span>168<span class="token punctuation">.</span>1<span class="token punctuation">.</span>66 dev server_networkdocker network create <span class="token operator">-</span>d macvlan <span class="token operator">--</span>subnet=192<span class="token punctuation">.</span>168<span class="token punctuation">.</span>1<span class="token punctuation">.</span>0/24 <span class="token operator">--</span>gateway=192<span class="token punctuation">.</span>168<span class="token punctuation">.</span>1<span class="token punctuation">.</span>1 <span class="token operator">-</span>o parent=wlp2s0b1 docker_network ip link add server_network link wlp2s0b1 <span class="token function">type</span> macvlan mode bridge ip addr add 192<span class="token punctuation">.</span>168<span class="token punctuation">.</span>1<span class="token punctuation">.</span>45 dev server_network ip link <span class="token function">set</span> server_network up ip route add 192<span class="token punctuation">.</span>168<span class="token punctuation">.</span>1<span class="token punctuation">.</span>66 dev server_networkdocker network create -d macvlan --subnet=192.168.1.0/24 --gateway=192.168.1.1 -o parent=wlp2s0b1 docker_network ip link add server_network link wlp2s0b1 type macvlan mode bridge ip addr add 192.168.1.45 dev server_network ip link set server_network up ip route add 192.168.1.66 dev server_network
docker-compose.yaml
<span class="token key atrule">version</span><span class="token punctuation">:</span> <span class="token string">'3'</span> <span class="token key atrule">services</span><span class="token punctuation">:</span> <span class="token key atrule">wxy</span><span class="token punctuation">:</span> <span class="token key atrule">image</span><span class="token punctuation">:</span> onething1/wxedge<span class="token punctuation">:</span>latest <span class="token key atrule">container_name</span><span class="token punctuation">:</span> wxy <span class="token key atrule">hostname</span><span class="token punctuation">:</span> wxy <span class="token key atrule">restart</span><span class="token punctuation">:</span> always <span class="token key atrule">privileged</span><span class="token punctuation">:</span> <span class="token boolean important">true</span> <span class="token key atrule">tmpfs</span><span class="token punctuation">:</span> <span class="token punctuation">-</span> /tmp <span class="token punctuation">-</span> /run <span class="token key atrule">volumes</span><span class="token punctuation">:</span> <span class="token punctuation">-</span> /home/qiang/data/wxy<span class="token punctuation">:</span>/storage<span class="token punctuation">:</span>rw <span class="token key atrule">networks</span><span class="token punctuation">:</span> <span class="token key atrule">default</span><span class="token punctuation">:</span> <span class="token key atrule">ipv4_address</span><span class="token punctuation">:</span> 192.168.1.66 <span class="token key atrule">networks</span><span class="token punctuation">:</span> <span class="token key atrule">default</span><span class="token punctuation">:</span> <span class="token key atrule">external</span><span class="token punctuation">:</span> <span class="token key atrule">name</span><span class="token punctuation">:</span> docker_network<span class="token key atrule">version</span><span class="token punctuation">:</span> <span class="token string">'3'</span> <span class="token key atrule">services</span><span class="token punctuation">:</span> <span class="token key atrule">wxy</span><span class="token punctuation">:</span> <span class="token key atrule">image</span><span class="token punctuation">:</span> onething1/wxedge<span class="token punctuation">:</span>latest <span class="token key atrule">container_name</span><span class="token punctuation">:</span> wxy <span class="token key atrule">hostname</span><span class="token punctuation">:</span> wxy <span class="token key atrule">restart</span><span class="token punctuation">:</span> always <span class="token key atrule">privileged</span><span class="token punctuation">:</span> <span class="token boolean important">true</span> <span class="token key atrule">tmpfs</span><span class="token punctuation">:</span> <span class="token punctuation">-</span> /tmp <span class="token punctuation">-</span> /run <span class="token key atrule">volumes</span><span class="token punctuation">:</span> <span class="token punctuation">-</span> /home/qiang/data/wxy<span class="token punctuation">:</span>/storage<span class="token punctuation">:</span>rw <span class="token key atrule">networks</span><span class="token punctuation">:</span> <span class="token key atrule">default</span><span class="token punctuation">:</span> <span class="token key atrule">ipv4_address</span><span class="token punctuation">:</span> 192.168.1.66 <span class="token key atrule">networks</span><span class="token punctuation">:</span> <span class="token key atrule">default</span><span class="token punctuation">:</span> <span class="token key atrule">external</span><span class="token punctuation">:</span> <span class="token key atrule">name</span><span class="token punctuation">:</span> docker_networkversion: '3' services: wxy: image: onething1/wxedge:latest container_name: wxy hostname: wxy restart: always privileged: true tmpfs: - /tmp - /run volumes: - /home/qiang/data/wxy:/storage:rw networks: default: ipv4_address: 192.168.1.66 networks: default: external: name: docker_network
访问地址
http:<span class="token operator">/</span><span class="token operator">/</span>192<span class="token punctuation">.</span>168<span class="token punctuation">.</span>1<span class="token punctuation">.</span>66:18888http:<span class="token operator">/</span><span class="token operator">/</span>192<span class="token punctuation">.</span>168<span class="token punctuation">.</span>1<span class="token punctuation">.</span>66:18888http://192.168.1.66:18888
作者(Author):小强崽
来源(Source):https://www.wuduoqiang.com/archives/Docker安装网心云
协议(License):署名-非商业性使用-相同方式共享 4.0 国际 (CC BY-NC-SA 4.0)
版权(Copyright):商业转载请联系作者获得授权,非商业转载请注明出处。 For commercial use, please contact the author for authorization. For non-commercial use, please indicate the source.
原文链接:https://blog.csdn.net/wdq875667601/article/details/126396124?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522171836840916800226555627%2522%252C%2522scm%2522%253A%252220140713.130102334.pc%255Fblog.%2522%257D&request_id=171836840916800226555627&biz_id=0&utm_medium=distribute.pc_search_result.none-task-blog-2~blog~first_rank_ecpm_v1~times_rank-18-126396124-null-null.nonecase&utm_term=docker%E3%80%81%E5%A5%BD%E7%94%A8