0
votes

I'm new to docker and am stuck on correctly exposing ports for psiturk.

I have a docker-compose.yml file that creates a psiturk container, a nginx container, an adminer container, and a mysql container. I am attempting to run the psiturk experiment in sandbox mode on mTurk. The server cannot connect. I've exposed the ports. When I run psiturk outside of Docker, I can run an experiment in sandbox so it's not my computer's firewall.

I've heard of publishing exposed ports and attempted this by adding:

ports:
     - 22362:22362

to the psiturk container, but it didn't work.

For my docker-compose.yml file:

version: '3'

services:

  psiturk:
    container_name: my-experiment
    build: .
    volumes:
      - ./exp:/exp
    tty: true
    stdin_open: true
    restart: unless-stopped

  nginx:
    container_name: my-experiment-nginx
    image: nginx:latest
    ports:
      - 80:80
    volumes:
      - ./exp:/var/www/exp:ro
      - ./default.conf:/etc/nginx/conf.d/default.conf
    restart: unless-stopped

  db:
    container_name: my-experiment-db
    image: mysql:5.7
    volumes:
      - ./data/db:/var/lib/mysql
    environment:
      MYSQL_ROOT_PASSWORD: anothersafepassword
      MYSQL_DATABASE: shared4data
      MYSQL_USER: jorja
      MYSQL_PASSWORD: totallysafepassword
    restart: unless-stopped

  adminer:
    container_name: my-experiment-adminer
    image: adminer:latest
    ports:
      - 127.0.0.1:8080:8080

For my dockerfile:

FROM python:3.6-stretch

LABEL maintainer="Jorja Shires <[email protected]>" version="1.0"

ENV PSITURK_GLOBAL_CONFIG_LOCATION "/exp"

WORKDIR "/exp"

RUN pip install \
        psiturk==2.3.8 \
        pymysql==0.10.0 \
        python-Levenshtein==0.12.0 \
    && rm -rf ~/.cache/pip

CMD ["bash"]

EXPOSE 22362
EXPOSE 80

For my psiturk config file:

[Server Parameters]
host = 0.0.0
port = 22362
cutoff_time = 30
logfile = server.log
loglevel = 2
debug = true
threads = auto
adserver_revproxy_host = MyStaticIPAddress
adserver_revproxy_port = 80 

[Shell Parameters]
launch_in_sandbox_mode = true
#bonus_message = "Thanks for participating!"
use_psiturk_ad_server = true
ad_location = false
1

1 Answers

0
votes

Oh hey, looks like you're using my experiment template: https://github.com/paxtonfitzpatrick/psiturk-experiment-template

I think there are two issues going on here:

  1. In your exp/config.txt file, the "host" field is 0.0.0 but should be 0.0.0.0.

  2. There were updates made to both the psiTurk Python package and the psiTurk ad server (which hosts your ad.html) a few months ago that broke a lot of existing experiment setups. In particular, according to the psiTurk README:

    Versions less than v2.3.12 will not be able to post HITs due to a change implemented by the psiturk ad server's hosting provider.

    So the psiTurk version installed in your Dockerfile (2.3.8) will no longer work. I'll update the experiment template repository soon, but the general steps to upgrade from the current version are:

    • in your Dockerfile, replace psiturk==2.3.8 with psiturk==2.3.12
    • remove all comments from exp/templates/ad.html (for whatever reason, they cause issues with the updated ad server)
    • in config.txt, under [Shell Parameters], make sure use_psiturk_ad_server is explicitly set to true and ad_location is explicitly set to false

It's also worth noting that psiTurk v3.0 has dropped support for the psiturk.org ad server altogether, so it seems likely that at some point in the future, the psiTurk maintainers will simply stop managing it and you'll have to set up your own ad server (the docs recommend Heroku). But for now (and hopefully for a while yet!) the steps above should suffice.