Running wpt server and agent with docker-compose

Hi,

I’m trying to setup a server and an agent using docker and docker-compose, both running on the same machine (my laptop). No matter how I set the compose file I cannot get the agent to show up in the Test Location combo. This is my locations.ini:

[quote]root@8a37986239aa:/var/www/html# cat settings/locations.ini
[locations]
1=Test_loc
default=Test_loc

[Test_loc]
1=Test
label=“Test Location”
;group=Desktop

[Test]
browser=Chrome
label=“Test Location”[/quote]

When starting the containers with this docker-compose.yml file, mapping server’s container port to a host port and exposing the agent’s port:

version: "2.2" services: wpt_server: #The Dockerfile just adds location.ini and server.ini build: . image: webpagetest/server:custom volumes: - ./volumes/wpt_data/dat:/var/www/html/dat - ./volumes/wpt_data/results:/var/www/html/results - ./volumes/wpt_data/logs:/var/www/html/logs ports: - 4000:80 wpt_agent: image: webpagetest/agent:latest init: true environment: SERVER_URL: http://wpt_server/work/ LOCATION: Test EXTRA_ARGS: "-m debug --checknet yes --log /debug.log -vvvv" NAME: "Docker Test" depends_on: - wpt_server cap_add: - NET_ADMIN

I get this error:

[code]wpt_agent_1 | 03:22:06.880 - Resetting dropped connection: wpt_server
wpt_agent_1 | 03:22:06.881 - http://wpt_server:80 “GET /work/getwork.php?f=json&shards=1&reboot=1&location=Test&pc=Docker&version=18.10&screenwidth=1920&screenheight=1200&freedisk=0.760&upminutes=8866 HTTP/1.1” 400 422

[/code]

And when also mapping agent port and using http://localhost:4000 instead of http://wpt_server for SERVER_URL:

version: "2.2"
services:
  wpt_server:
    build: .
    image: webpagetest/server:latest
    volumes:
      - ./volumes/wpt_data/dat:/var/www/html/dat
      - ./volumes/wpt_data/results:/var/www/html/results
      - ./volumes/wpt_data/logs:/var/www/html/logs
    ports:
      - 4000:80
  wpt_agent:
    image: webpagetest/agent:test
    init: true
    environment:
      SERVER_URL: http://localhost:4000/work/
      LOCATION: Test
      EXTRA_ARGS: "-m debug --checknet yes --log /debug.log -vvvv"
      NAME: "Docker Test"
    depends_on:
      - wpt_server
    cap_add:
      - NET_ADMIN
    ports:
      - 4001:80

From the agent side everything seems fine, I see on the the agent logs these messages that seems to mean that everything is working ok but not getting any work from the server ?

wpt_agent_1 | 04:21:00.931 - Checking for work: http://localhost:4000/work/getwork.php?f=json&shards=1&reboot=1&location=Test&pc=Docker&version=18.10&screenwidth=1920&screenheight=1200&freedisk=0.759&upminutes=8925 wpt_agent_1 | 04:21:00.933 - Starting new HTTP connection (1651): localhost:4000 wpt_agent_1 | 04:21:00.934 - Get Work Error: None wpt_agent_1 | sudo: reboot: command not found

But still the agent does not show up on the Test Location combo and no errors on the server logs, I’m really clueless with what I’m missing. Any ideas ??

Thanks in advance.

Got it working, privileged:true and network_mode: “host” parameters are needed, it seems it’s not enough with cap_add: NET_ADMIN. This is the docker-compose.yml file that is working for me:

version: "2.2" services: wpt_server: build: . image: webpagetest/server:custom volumes: - ./volumes/wpt_data/dat:/var/www/html/dat - ./volumes/wpt_data/results:/var/www/html/results - ./volumes/wpt_data/logs:/var/www/html/logs ports: - 4000:80 wpt_agent: image: webpagetest/agent init: true environment: SERVER_URL: http://localhost:4000/work/ LOCATION: desktop EXTRA_ARGS: "-m debug --checknet yes --log /debug.log -vvvv" depends_on: - wpt_server privileged: true network_mode: "host"

It seems that the key part is the privileged: true parameter, I also got it working behind a traefik proxy with this docker-compose file. The main difference with the previous one is neither the server or agent are mapping ports to the server, the server is accessed through traefik:

[code]version: “2”
services:
server:
image: wepagetest/server:custom
volumes:
- ./webpagetest/volumes/wpt_data/dat:/var/www/html/dat
- ./webpagetest/volumes/wpt_data/results:/var/www/html/results
- ./webpagetest/volumes/wpt_data/logs:/var/www/html/logs
labels:
traefik.enable: true
traefik.backend: server
traefik.frontend.rule: Host:wpt.apukay.com
traefik.port: 80
restart: always

agent:
image: webpagetest/agent
init: true
environment:
SERVER_URL: http://server/work/
LOCATION: desktop
EXTRA_ARGS: “-m debug --checknet yes --log /debug.log -vvvv”
depends_on:
- server
cap_add:
- NET_ADMIN
privileged: true
[/code]