一、镜像篇
1. 查看所有镜像
sudo docker image ls --all
2. 拉取镜像
sudo docker image pull v2ray/official
sudo docker image pull 镜像名称:版本号 # 不指定版本默认为最新版
3. 删除镜像
sudo docker image rm v2ray/official
sudo docker image rm 镜像名称/镜像ID
二、容器篇
1. 创建容器[必须现有镜像,才能创建运行容器]
sudo docker run -d --name v2ray9999 -v /etc/v2ray:/etc/v2ray -p 9999:9999 v2ray/official v2ray -config=/etc/v2ray/config.json
sudo docker run [option] 镜像名 [向启动容器中传入的命令] # 创建容器
- 如果 V2Ray 用的传输层协议是 mKCP,由于 mKCP 基于 UDP,那么需要指定映射的端口是 UDP:
sudo docker run -d --name v2ray -v /etc/v2ray:/etc/v2ray -p 9999:9999/udp v2ray/official v2ray -config=/etc/v2ray/config.json
2. 查看所有的容器
sudo docker ps -a
3.启动容器
sudo docker start v2ray9999 / 1e560fca3906
sudo docker start <容器名> / <容器 ID>
4. 重启容器
sudo docker restart v2ray9999 / 1e560fca3906
sudo docker restart <容器名> / <容器 ID>
5. 停止一个容器
sudo docker stop v2ray9999 / 1e560fca3906
sudo docker stop <容器名> / <容器 ID>
6. 删除容器
sudo docker rm -f v2ray9999 / 1e560fca3906
sudo docker rm -f <容器名> / <容器 ID>
三、配置篇
1. 服务器配置:
{
"inbounds": [
{
"port": 9999,
"protocol": "vmess",
"settings": {
"clients": [
{
"id": "7efe3638-7d05-4921-b5d1-cc92fe2ef0b8",
"level": 1,
"alterId": 64
}
]
},
"streamSettings": {
"network": "tcp",
"tcpSettings": {
"header": {
"type": "http",
"response": {
"version": "1.1",
"status": "200",
"reason": "OK",
"headers": {
"Content-Type": [
"application/octet-stream",
"application/x-msdownload",
"text/html",
"application/x-shockwave-flash"
],
"Transfer-Encoding": [
"chunked"
],
"Connection": [
"keep-alive"
],
"Pragma": "no-cache"
}
}
}
}
}
}
],
"outbounds": [
{
"protocol": "freedom",
"settings": {}
},
{
"protocol": "blackhole",
"settings": {},
"tag": "blocked"
}
]
}
2. 客户端配置:
{
"log": {
"access": "",
"error": "",
"loglevel": "warning"
},
"inbound": {
"port": 1080,
"listen": "127.0.0.1",
"protocol": "socks",
"settings": {
"auth": "noauth",
"udp": true,
"ip": "127.0.0.1",
"clients": null
},
"streamSettings": null
},
"outbound": {
"tag": "agentout",
"protocol": "vmess",
"settings": {
"vnext": [
{
"address": "13.56.85.128",
"port": 9999,
"users": [
{
"id": "7efe3638-7d05-4921-b5d1-cc92fe2ef0b8",
"alterId": 64,
"email": "t@t.tt",
"security": "chacha20-poly1305"
}
]
}
],
"servers": null
},
"streamSettings": {
"network": "tcp",
"security": "",
"tlsSettings": null,
"tcpSettings": {
"connectionReuse": true,
"header": {
"type": "http",
"request": {
"version": "1.1",
"method": "GET",
"path": [
"/"
],
"headers": {
"Host": [
"baidu.com"
],
"User-Agent": [
"Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.75 Safari/537.36",
"Mozilla/5.0 (iPhone; CPU iPhone OS 10_0_2 like Mac OS X) AppleWebKit/601.1 (KHTML, like Gecko) CriOS/53.0.2785.109 Mobile/14A456 Safari/601.1.46"
],
"Accept-Encoding": [
"gzip, deflate"
],
"Connection": [
"keep-alive"
],
"Pragma": "no-cache"
}
},
"response": {
"version": "1.1",
"status": "200",
"reason": "OK",
"headers": {
"Content-Type": [
"application/octet-stream",
"video/mpeg"
],
"Transfer-Encoding": [
"chunked"
],
"Connection": [
"keep-alive"
],
"Pragma": "no-cache"
}
}
}
},
"kcpSettings": null,
"wsSettings": null,
"httpSettings": null
},
"mux": {
"enabled": true
}
},
"inboundDetour": null,
"outboundDetour": [
{
"protocol": "freedom",
"settings": {
"response": null
},
"tag": "direct"
},
{
"protocol": "blackhole",
"settings": {
"response": {
"type": "http"
}
},
"tag": "blockout"
}
],
"dns": {
"servers": [
"8.8.8.8",
"8.8.4.4",
"localhost"
]
},
"routing": {
"strategy": "rules",
"settings": {
"domainStrategy": "IPIfNonMatch",
"rules": [
{
"type": "field",
"port": null,
"outboundTag": "direct",
"ip": [
"0.0.0.0/8",
"10.0.0.0/8",
"100.64.0.0/10",
"127.0.0.0/8",
"169.254.0.0/16",
"172.16.0.0/12",
"192.0.0.0/24",
"192.0.2.0/24",
"192.168.0.0/16",
"198.18.0.0/15",
"198.51.100.0/24",
"203.0.113.0/24",
"::1/128",
"fc00::/7",
"fe80::/10"
],
"domain": null
}
]
}
}
}
网友评论