There is a detailed description how to use gitlab as a Docker registry at
- https://docs.gitlab.com/ee/user/packages/container_registry/
- https://docs.gitlab.com/ee/ci/docker/using_docker_build.html
Following the instructions will get you very close. To create a test-case on gitlab.desy.de you essentially need only a few ingredients:
- a Dockerfile containing the Docker image build instructions
- CI/CD integration to automatically build images
- possibly an access token
CI/CD
The CI/CD integration file in the test-case looks like this
#image: gitlab/dind stages: - build build-crystfel: stage: build image: docker:19.03.13 services: - docker:19.03.12-dind variables: IMAGE_TAG: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG DOCKER_HOST: tcp://docker:2375 DOCKER_TLS_CERTDIR: "" script: - docker info - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY - docker build -t $IMAGE_TAG . - docker push $IMAGE_TAG
Dockerfile
A Dockerfile can be a very simple "Hello World". I usually use crystfel as a test-case. A rather old and crude version looks like this:
Running the Docker image
On maxwell you should get a compute node (no docker on login nodes), and simply run your docker image. In my case that works like this:
dockerrun -it gitlab.desy.de:5555/frank.schluenzen/crystfel:master
To be able to do so, you must be authorized to access the docker registry, which can be done by creating an access token. More information can be found at https://docs.docker.com/engine/reference/commandline/login/. One caveat: you need to know the tag of the image. Docker will by default look for a tag latest and fail if it doesn't exist:
dockerrun -it gitlab.desy.de:5555/frank.schluenzen/crystfel docker: Error response from daemon: manifest for gitlab.desy.de:5555/frank.schluenzen/crystfel:latest not found: manifest unknown: manifest unknown
You can get the existing tags from the gitlab web, or via command line, for example
curl -s --header "PRIVATE-TOKEN: $(cat ~/.ssh/gitlab.crystfel.token)" https://gitlab.desy.de/api/v4/projects/106/repository/tags | jq '.[].name'
will list available tags. jp is a small json parser, python will do as well. master will not show up in the list of tags (not being a tag), but seems always a valid choice.