使用 Docker 部署时的容器名称

gin*_*boy 3 docker dokku

我刚刚完成了我的第一次 Docker 部署,当我运行这个命令来查看最近进程的状态时......

docker ps -a

我得到这个输出

码头工人输出

我的问题是;这些名字指的是什么?

Von*_*onC 5

这些是为您运行的每个容器生成的随机名称。
您可以在 中看到这些名称pkg/namesgenerator/names-generator.go

// Docker, starting from 0.7.x, generates names from notable scientists and hackers.
// Please, for any amazing man that you add to the list, consider adding an equally amazing woman to it, and vice versa.
right = [...]string{ 
    // Muhammad ibn J?bir al-?arr?n? al-Batt?n? was a founding father of astronomy. https://en.wikipedia.org/wiki/Mu%E1%B8%A5ammad_ibn_J%C4%81bir_al-%E1%B8%A4arr%C4%81n%C4%AB_al-Batt%C4%81n%C4%AB
    "albattani",

    // Frances E. Allen, became the first female IBM Fellow in 1989. In 2006, she became the first female recipient of the ACM's Turing Award. https://en.wikipedia.org/wiki/Frances_E._Allen
    "allen",
...
Run Code Online (Sandbox Code Playgroud)

您可以通过添加--name到您的docker run命令来获得固定名称。

这种做法是由Michael Crosby ( )在 2013 年 10 月为 docker 0.6.5 在commit 0d29244中引入的:crosbymichael

添加-namedocker run

删除 docker 链接
不要将容器 ID 添加为默认
名称 如果未在运行时指定,则创建自动生成的容器名称。

Solomon Hykes ( shykes)docker 0.7 中使用commit 5d6ef317 改进了这种做法:

0.7 的新随机名称集合:

心情+著名发明家。
例如。'sad-tesla' 或 'naughty-turing'