I have multiple microservices and I am using docker-compose for development deployments. When there are some changes in the microservices code base, I am triggering ci job to re-deploy them. I have below script to do this. But each time I have to build all images from scratch, then run them. After all of this operation, I have anonymous images. So I am using the last script to remove them. What you would suggest making this process more practical? Is there any way to update an existing image without removing it with new changes?
- docker-compose build
- docker-compose down
- docker-compose up -d --force-recreate
- docker rmi $(docker images -f "dangling=true" -q) -f
附加信息:我正在使用gitlab-ci
还有一个脚本,使用它可以一次更新许多docker-compose堆栈。
它被称为合成更新,可以在以下链接中找到:
https://github.com/FrederikRogalski/compose-update
合成-更新docker-合成-图像-更新器
这个python脚本自动更新一个或多个docker-compose堆栈的映像。
如果提供了多个docker-compose目录,脚本将并行更新它们。
Demo
使用
Usage: compose-update [OPTIONS] [UPDATE_DIRS]...
Update docker-compose images automatically.
Takes one or more directorys as input and searches for a
compose file in one of the following forms:
"compose.yaml", "compose.yml", "docker-compose.yaml",
"docker-compose.yml"
Options:
--prune / --no-prune Prune docker images after update
process if set
--help Show this message and exit.
安装
git clone https://github.com/FrederikRogalski/compose-update.git
cd compose-updater
chmod +x update-compose
然后将文件“update-compose”添加到您的路径。
还有一个脚本,使用它可以一次更新许多docker-compose堆栈。
它被称为合成更新,可以在以下链接中找到:
https://github.com/FrederikRogalski/compose-update
合成-更新docker-合成-图像-更新器
这个python脚本自动更新一个或多个docker-compose堆栈的映像。
如果提供了多个docker-compose目录,脚本将并行更新它们。
Demo
使用
Usage: compose-update [OPTIONS] [UPDATE_DIRS]...
Update docker-compose images automatically.
Takes one or more directorys as input and searches for a
compose file in one of the following forms:
"compose.yaml", "compose.yml", "docker-compose.yaml",
"docker-compose.yml"
Options:
--prune / --no-prune Prune docker images after update
process if set
--help Show this message and exit.
安装
git clone https://github.com/FrederikRogalski/compose-update.git
cd compose-updater
chmod +x update-compose
然后将文件“update-compose”添加到您的路径。