Reputation: 867
I have a simple project setup in Gitlab CI/CD using Docker to serve the site on a Container following this guide. But I get "Container already in use..." error whenever there is a new job running on a push event. How do I "push" the new code to my already running website without taking it down or killing the container?
# .gitlab-ci.yml
stages:
- build
job 1:
stage: build
tags:
- windows-test
script:
- docker build -t vuejs-cookbook/dockerize-vuejs-app .
- docker run -p 8080:80 --rm --name dockerize-vuejs-app-1 vuejs-cookbook/dockerize-vuejs-app
Upvotes: 2
Views: 341
Reputation: 11042
The container name is the same every time. Stop and remove the old container first.
Run docker stop dockerize-vuejs-app-1
and docker rm dockerize-vuejs-app-1
after docker build
.
Beside that I would suggest to run your container detached (-d
) with --restart always
(docs).
docker build -t vuejs-cookbook/dockerize-vuejs-app .
docker stop dockerize-vuejs-app-1
docker rm dockerize-vuejs-app-1
docker run -p 8080:80 -d --restart always --name dockerize-vuejs-app-1 vuejs-cookbook/dockerize-vuejs-app
Upvotes: 2