如何从里面获取容器名称? docker.io [英] how to get container name from inside? docker.io

查看:308
本文介绍了如何从里面获取容器名称? docker.io的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何从容器内部获取docker的容器名称?

How can I get docker's container name from inside the container?

我不能使用检查因为我必须使用容器内的脚本才能获取信息从json url。

I can't use inspect becouse I have to use an script from inside the container to get info from a json url.

谢谢

推荐答案

如果你的意思是作为主机名变量的env中可用的容器ID。它应该与大多数操作的名称互换。

If you mean the Container ID its available in the env as the hostname variable. It should be interchangeable with the name for most operations.

env
HOSTNAME=5252eb24b296
TERM=xterm
....

CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
5252eb24b296        ubuntu:14.04        "bash"              23 seconds ago      Up 22 seconds                           test

这篇关于如何从里面获取容器名称? docker.io的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆