diff --git a/README.md b/README.md
index cbad97b2b33e68214266674f1f051f933157d617..07c5f28104bd4118166799c031366f6289b75674 100644
--- a/README.md
+++ b/README.md
@@ -13,7 +13,7 @@ This is the MIP backend.
 
 ## Usage in building environment
 
-* Build a versioned image: `./captain_build.sh` or `captain build`
+* Build a versioned image: `./captain_build.sh` (only if `$WORKSPACE=$(pwd)`) or `export WORKSPACE=<path-to-workspace> && captain build`
 * Build and test an image: `./captain_test.sh` or `captain test`
 * Run the latest image with a non-persistent postgres (only use this for testing purpose): `./captain_run.sh`
 
diff --git a/captain.yml b/captain.yml
index 966005776f161660d288b909f7f58918d364712b..f5f137b5c21279809feb19d4860543c0fa8589a0 100644
--- a/captain.yml
+++ b/captain.yml
@@ -4,7 +4,7 @@ portal-backend-build:
   pre:
     - echo 'Building portal-backend-build'
   post:
-    - docker run --rm -v $(pwd):/opt/portal/ -v $(pwd)/.m2:/root/.m2/ hbpmip/portal-backend-build
+    - docker run --rm -v $WORKSPACE:/opt/portal/ -v $WORKSPACE/.m2:/root/.m2/ hbpmip/portal-backend-build
     - echo 'Finished building portal-backend-build'
   test:
     - ./tests/test-build.sh
@@ -17,10 +17,10 @@ portal-backend:
     - cp -r $(pwd)/config/ $(pwd)/src/docker/run/config/
     - cp -r $(pwd)/target/ $(pwd)/src/docker/run/target/
   post:
-    - rm -rf $(pwd)/src/docker/run/target/
-    - rm -rf $(pwd)/src/docker/run/config/
+    - rm -rf $WORKSPACE/src/docker/run/target/
+    - rm -rf $WORKSPACE/src/docker/run/config/
     - echo 'Finished building portal-backend'
   test:
     - ./tests/pre-test-run.sh
     - ./tests/test-run.sh
-    - ./tests/post-test-run.sh
\ No newline at end of file
+    - ./tests/post-test-run.sh
diff --git a/captain_build.sh b/captain_build.sh
index 7e11462e1e3ef26549e2a077a30a0d7d41da03fe..b524f3458aabc7a22c277bff1f0c92aec25516fe 100755
--- a/captain_build.sh
+++ b/captain_build.sh
@@ -1,3 +1,4 @@
 #!/usr/bin/env bash
 
+export WORKSPACE=$(pwd)
 captain build