Configure host and port when starting clojure's boot

When you start boot it is possible to set host and port number the repl server will bind to. Just pass the -b and -p parameters.

boot repl -b -p 40001"

Passing these parameters is necessary when you want to start a repl via boot in a docker container and then do interactive development with that container.

Try it for yourself, you can use the following docker-compose.yml file

version: "2.1"

    image: clojure:boot-alpine
    working_dir: /usr/src/app
      - .:/usr/src/app
      - BOOT_LOCAL_REPO=/usr/src/app/.m2
      - REPL_PORT
      - REPL_HOST
      - "${REPL_PORT}:${REPL_PORT}"
    command: "boot repl -b ${REPL_HOST} -p ${REPL_PORT}"

And don’t forget to set the .env file:


Then to start you just need to run:

docker-compose run --service-ports repl


  • --service-ports parameter tells docker-compose to use the specified ports.
  • BOOT_LOCAL_REPO env var indicates where to store the dependencies. Here we’re pointing them to /usr/src/app/.m2 that is mapped to the current host directory. This way whenever you start new repl containers they will not need to “refetch” the dependencies.

If you liked this post, you can share it with your followers or follow me on Twitter!