迹忆客 EN >

当前位置:主页 > 学无止境 > 操作系统 > Docker >

使用 Docker Compose 更新现有镜像

作者:迹忆客 最近更新:2023/04/17 浏览次数:

Docker 容器设计为一次性且易于更换。 因此,只要容器的基础镜像收到更新,我们就应该拉取更新后的镜像并启动容器的新实例。

本文将讨论如何使用 docker-compose 更新现有镜像。


使用 Docker Compose 更新现有镜像

确保在使用新镜像更新容器之前已下载所有照片,以最大限度地减少在镜像下载失败的情况下处于中间状态或处于中间状态的时间。

  1. 使用以下代码段更新最新镜像。
    $ docker-compose pull
    
  2. 使用以下命令重新启动容器。 上面的代码片段只会重新创建更改的容器。 我们还可以在此命令上附加 --force-recreate; 但是,这只会重新创建未更改的容器。
    $ docker-compose up -d --remove-orphans
    
  3. 作为可选步骤,删除任何过时的镜像。
    $ docker image prune
    
    对于最后一步,我们不需要使用 -f--force-recreate 参数,因为这可能会对我们的图像造成破坏性的副作用。

转载请发邮件至 1244347461@qq.com 进行申请,经作者同意之后,转载请以链接形式注明出处

本文地址:

相关文章

Solution to incorrect access log time when deploying Nginx in Docker

发布时间:2025/03/26 浏览次数:165 分类:Docker

In the process of operating the website, I never took the logs too seriously. Although logging was turned on, I never analyzed the logs carefully. Today, when I looked at the logs on a whim, I found that the recorded time was 8 hours less t

Docker deploys nginx php application

发布时间:2025/03/26 浏览次数:131 分类:Docker

I'm learning docker recently. I'm learning by building an nginx+php development environment example. Here I record the build process. First, give a docker-compose.yml deployment configuration file version: '3' services: nginx: container_nam

How to use Docker to image a Node.js web application

发布时间:2025/03/26 浏览次数:107 分类:Docker

Docker is a containerization platform that simplifies the packaging and execution of applications. Containers run as independent processes with their own file systems, but share the kernel of their host machine. Docker has attracted much at

Start a Bash terminal in a new Docker container

发布时间:2025/03/26 浏览次数:97 分类:Docker

Docker containers are a standard unit for packaging all the dependencies of an application, allowing us to easily run them in any environment. Containers have become very popular recently, and most developers now rely heavily on containers

Passing environment variables to containers in Docker

发布时间:2025/03/26 浏览次数:124 分类:Docker

This article will introduce how to pass environment variables to containers in Docker. Passing environment variables to containers in Docker using the -e and tags -env We will first see how to create environment variables and pass them to t

Install Docker using Homebrew

发布时间:2025/03/26 浏览次数:202 分类:Docker

There is no doubt that Docker containers have revolutionized the way we develop and deploy applications. They provide developers with the ability to package applications and dependencies in an isolated environment. Recently, we've seen wide

Enforce clean build of images in Docker

发布时间:2025/03/26 浏览次数:87 分类:Docker

This article discusses and demonstrates how to enforce clean builds of images in Docker. Building images in Docker We will use a simple Flask application to demonstrate this concept. my-app Create a app.py simple application named in the ho

Running a Docker instance from a Dockerfile

发布时间:2025/03/26 浏览次数:140 分类:Docker

Docker containers have undoubtedly become the standard unit for managing software and dependencies in different environments. When using real applications, you must create a docker file before building the container image of the application

扫一扫阅读全部技术教程

社交账号
  • https://www.github.com/onmpw
  • qq:1244347461

最新推荐

教程更新

热门标签

扫码一下
查看教程更方便