迹忆客 EN >

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

在 Docker 中重命名镜像

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

在 Docker 中,我们可以使用一种简单的方法来重命名镜像,而无需从头开始重建它。 本文将讨论如何使用 Docker 重命名镜像。


在 Docker 中重命名图像

我们可以通过更改图像标签来重命名镜像或更改存储库名称。 我们记得标签只是完整镜像名称的人类可读别名。

$ docker image tag server:latest sample/server:latest

或者

$ docker image tag d583c3ac35fd sample/server:latest

作为一种速记方法,我们可以运行以下代码片段:

$ docker tag d58 sample/server:latest

参数 d58 表示镜像 ID 的前三个字符。 在这种情况下,我们只需要这几个字符。


删除旧镜像作为最佳实践

最后,我们可以删除旧镜像,让尽可能多的标签与同一镜像相关联。 如果我们不喜欢旧的镜像名称,我们可以在重新标记后将其删除:

$ docker rmi server

该命令将删除别名/标记标记格式。 然而,由于 d58... 有其他名称,Docker 不会删除实际的镜像。

转载请发邮件至 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

最新推荐

教程更新

热门标签

扫码一下
查看教程更方便