Docker服务中的Docker容器ID唯一性

Docker服务中的Docker容器ID唯一性

另一个相对问题: https://forums.docker.com/t/docker-container-id-uniqueness/5253 更新:能否请您指出验证该容器ID是否已存在的代码以创建一个新的代码?解决方案在给定的Docker主机中,该ID必须在当前存在的所有容器(包括已退出和已创建的容器)中唯一.删除后,引擎将不再跟踪容器ID.容器可能会重复使用与以前存在的容器相同的容器ID,但是可能性很低.完整ID是64个字符的十六进制字符串,它给出16 ^ 64个可能的排列(如果我的计算器正确,则为115792089237316195423570985008687907853269984665640564039457584007913129639936).如果仅跟踪短ID,则为12个字符的十六进制字符串,排列顺序为16 ^ 12(281,474,976,710,656).如果您创建了大量的容器,并且需要历史地且唯一地进行跟踪,那么您可能要使用完整的容器ID.I have read how the containers are assigned the containers IDs: How the docker container id is generatedHow is the docker ID uniqueness verified?And in which pool is it unique?Among all exited, among all running, among all deleted/removed, among all ever created by a specific docker service?I was wondering whether the container ID is a reusable value, since it comes from a random number, how likely is it that a new container will have exactly the same container ID as another one (exited, deleted etc)?Another relative issue: https://forums.docker.com/t/docker-container-id-uniqueness/5253UPDATE: Could you please point me to the code that verifies that if the container ID already exists in creates a new one? 解决方案 The ID needs to be unique within a given docker host among all containers that currently exist (including exited and created containers). Once deleted, the engine no longer tracks the container ID. A container could potentially reuse the same container ID as a previously existing container, but the odds of that are fairly low.The full ID is a 64 character hex string, which gives 16^64 possible permutations (115792089237316195423570985008687907853269984665640564039457584007913129639936 if my calculator is correct). If you only track the short ID's, that's a 12 character hex string, with 16^12 (281,474,976,710,656) permutations. If you create a significant number of containers and need to track them historically and uniquely, then you may want to use the full container ID. 这篇关于Docker服务中的Docker容器ID唯一性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
09-02 20:24