安装与运行
拉取镜像
1
2
3docker pull webpagetest/server
docker pull webpagetest/agent运行实例
1
2
3docker run -d -p 4000:80 --rm webpagetest/server
docker run -d -p 4001:80 --network="host" -e "SERVER_URL=http://localhost:4000/work/" -e "LOCATION=Test" webpagetest/agent
mac 用户自定义镜像
创建server目录
1
2mkdir wpt-mac-server
cd wpt-mac-server创建Dockerfile,添加内容
1
2
3
4vim Dockerfile
FROM webpagetest/server
ADD locations.ini /var/www/html/settings/创建locations.ini配置文件,添加内容
1
2
3
4
5
6
7
8
9
10
11
12vim locations.ini
[locations]
1=Test_loc
[Test_loc]
1=Test
label=Test Location
group=Desktop
[Test]
browser=Chrome,Firefox
label="Test Location"
connectivity=LAN创建自定义server镜像
1
docker build -t wpt-mac-server .
创建agent目录
1
2mkdir wpt-mac-agent
cd wpt-mac-agent创建Dockerfile,添加内容
1
2
3
4
5vim Dockerfile
FROM webpagetest/agent
ADD script.sh /
ENTRYPOINT /script.sh创建script.sh, 添加内容
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17vim script.sh
#!/bin/bash
set -e
if [ -z "$SERVER_URL" ]; then
echo >&2 'SERVER_URL not set'
exit 1
fi
if [ -z "$LOCATION" ]; then
echo >&2 'LOCATION not set'
exit 1
fi
EXTRA_ARGS=""
if [ -n "$NAME" ]; then
EXTRA_ARGS="$EXTRA_ARGS --name $NAME"
fi
python /wptagent/wptagent.py --server $SERVER_URL --location $LOCATION $EXTRA_ARGS --xvfb --dockerized -vvvvv --shaper none修改script.sh权限
1
2
3chmod u+x script.sh
```
9. 创建自定义agent镜像docker build -t wpt-mac-agent .
1
10. 用新镜像运行实例 (注意先停掉之前运行的containers)
docker run -d -p 4000:80 –rm wpt-mac-server
docker run -d -p 4001:80 –network=”host” -e “SERVER_URL=http://localhost:4000/work/" -e “LOCATION=Test” wpt-mac-agent
`