Gitlab runner docker

Hello, everyone,

i use a Gitlab runner for my deployment. every deployment now creates a docker container, but it is not removed anymore. how can i optimize this?

my code looks like this

  S3_BUCKET_NAME: "bitbucket-repositories"

deploy to production:
  environment: production
  image: python:latest
- pip install awscli
- apt-get update
- apt-get -y install curl
- apt-get -y install sudo
#    - apt-get -y install libjpeg62
#    - apt-get -y install automake
- curl -sL | sudo -E bash -
- apt-get -y install nodejs
- cd app
- npm install
#    - echo "deb xenial main" | sudo tee -a /etc/apt/sources.list && sudo apt-get update && sudo apt install -y --allow-unauthenticated libpng12-0
- npm run buildNewVersion
- cd build
- rm bundle.js
- mv bundle.js.gz bundle.js
- cd ..
- npm run awsdeploy

many thanks in advance

the only thing that I can think of is that your last commando doesn’t exit but keeps running. Does the runner itself says it’s finsished?

yes it says job is done.

is there an exit command which I can add?

You can check the exit status of the command, but I expect that to be 0.
After thinking a bit more: The npm normally runs an nodejs server as far as I know, and when that is started it detaches from the shell, so a command within the container keeps running, however: gitlab runner has executed all command with succes, so the runner thinks it’s done but the docker container keeps running as it is still doing something (running npm).
What might be best to do is to create a container from this build and push it to the registry. You can then deploy it on the environment where you want to run your container (with docker compose, kubernetes or any other deployment method).