使用 docker-compose 1.19up
docker-compose up --build --force-recreate --no-deps [-d] [<service_name>..]
如果没有一个或多个service_name
参数,则将构建所有图像(如果丢失)并且将重新创建所有容器。
从帮助菜单
Options:
-d, --detach Detached mode: Run containers in the background,
print new container names. Incompatible with
--abort-on-container-exit.
--no-deps Don't start linked services.
--force-recreate Recreate containers even if their configuration
and image haven't changed.
--build Build images before starting containers.
无缓存
要强制重建忽略缓存层,我们必须首先构建一个新图像
docker-compose build --no-cache [<service_name>..]
从帮助菜单
Options:
--force-rm Always remove intermediate containers.
-m, --memory MEM Set memory limit for the build container.
--no-cache Do not use cache when building the image.
--no-rm Do not remove intermediate containers after a successful build.
然后重新创建容器
docker-compose up --force-recreate --no-deps [-d] [<service_name>..]