Dockerfile and .gitlab-ci.yml

I wrote a Dockerfile for JupytherHub. Using GitLab’s Docker registry, I created the image and the container. Now I would like to use a .gitlab-ci.yml JupyterHub in a subdomain. Delivering and starting the container does not work. Please have a look at the gitlab-ci.yml and the Dockerfile.

The second question is how to fix this problem?

$ echo "$GITLAB_PASSWORD" | docker login registry.gitlab.com --username $GITLAB_USER --password-stdin
WARNING! Your password will be stored unencrypted in /root/.docker/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-store

The Dockerfile

FROM continuumio/miniconda3

MAINTAINER

# Updating packages
RUN apt-get update -y \
    && apt-get install -y --no-install-recommends \
       git \
       nano \
       unzip \
    && apt-get clean \
    && rm -rf /var/lib/apt/lists/*

# Install conda and Jupyter
RUN conda update -y conda
RUN conda install -c conda-forge jupyter_nbextensions_configurator \
    jupyterhub \
    jupyterlab \
    matplotlib \
    pandas \
    scipy

# Setup application
EXPOSE 8000

CMD ["jupyterhub", "--ip='*'", "--port=8000", "--no-browser", "--allow-root"]

The gitlab-ci.yml

image: docker:latest

variables:
  DOCKER_DRIVER: overlay
  CONTAINER_IMAGE: registry.gitlab.com/joklein
  DOCKER_IMAGE: jupyter
  TAG: 0.1.0

services:
  - docker:dind

stages:
  - build
  - test
  - release
  - deploy

before_script:
  - echo "$GITLAB_PASSWORD" | docker login registry.gitlab.com --username $GITLAB_USER --password-stdin

build:
  stage: build
  script:
    - docker build -t $CONTAINER_IMAGE/$DOCKER_IMAGE .
    - docker push $CONTAINER_IMAGE/$DOCKER_IMAGE

test:
  stage: test
  script:
    - docker pull $CONTAINER_IMAGE/$DOCKER_IMAGE
    - docker ps -a
    - docker run -d -p 8000:8000 --name $DOCKER_IMAGE $CONTAINER_IMAGE/$DOCKER_IMAGE
    - docker ps -a

release:
  stage: release
  script:
    - docker pull $CONTAINER_IMAGE/$DOCKER_IMAGE
    - docker tag  $CONTAINER_IMAGE/$DOCKER_IMAGE:latest $CONTAINER_IMAGE/$DOCKER_IMAGE:$TAG
    - docker push $CONTAINER_IMAGE/$DOCKER_IMAGE:$TAG
  only:
    - master

deploy:
  stage: deploy
  image: alpine:latest
  before_script:
    - apk update && apk add git openssh-client rsync
  script:
    - mkdir .public
    - cp -r * .public
    - mv .public public
    - ls -la public
    - mkdir "${HOME}/.ssh"
    - echo "${SSH_HOST_KEY}" > "${HOME}/.ssh/known_hosts"
    - echo "${SSH_PRIVATE_KEY}" > "${HOME}/.ssh/id_rsa"
    - chmod 700 "${HOME}/.ssh/id_rsa"
    - rsync -hrvz --delete --exclude=_ public/ user@example.com:www/jupyter/
  only:
    - master