diff --git a/.docker/Dockerfile b/.docker/Dockerfile
index 9a18861444e82e45961a8f831fd0bba526f9de7d..3ab23751df44a9df91e3dccabfbd2904aa795ecb 100644
--- a/.docker/Dockerfile
+++ b/.docker/Dockerfile
@@ -9,10 +9,11 @@ RUN apt-get update && \
 	 tox \
 	 -y
 COPY .docker/wait-for-it.sh /wait-for-it.sh
-ADD https://gitlab.com/api/v4/projects/13656973/repository/branches/dev \
+ARG PYLIB=dev
+ADD https://gitlab.com/api/v4/projects/13656973/repository/commits/${PYLIB} \
 	pylib_version.json
 RUN git clone https://gitlab.com/caosdb/caosdb-pylib.git && \
-   cd caosdb-pylib && pip3 install .
+   cd caosdb-pylib && git checkout ${PYLIB} && pip3 install .
 COPY . /git
 RUN rm -r /git/.git && mv /git/.docker/pycaosdb.ini /git 
 WORKDIR /git
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index e74e5380724ca9013cb1b1978ef0cda9783e3fbf..be3c255b625984a84ca590ad7f1be16eb1f1c805 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -123,6 +123,7 @@ build-testenv:
       - docker login -u indiscale -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
         # use here general latest or specific branch latest...
       - docker build 
+        --build-arg PYLIB=${PYLIB}
         --file .docker/Dockerfile
         -t $CI_REGISTRY_IMAGE:latest .
       - docker push $CI_REGISTRY_IMAGE:latest