Get container name inside the docker container

tony Kuo
Disassembly
Published in
2 min readApr 3, 2021

--

Docker-compose can easily launch multi-container with the config file (default: docker-compose.yml ). For example, we have the following files.

node
├── docker-compose.yml
└── get_name.sh

In docker-compose.yml

version: '2.3'services:    node:
image: alpine:3.13
volumes:
- ./:/root:z
entrypoint: /bin/sh
command: /root/get_name.sh

In get_name.sh

echo "hello world"

--

--

tony Kuo
Disassembly

追知識追夢追科技,喜歡新穎的事物及看法,更喜歡思考。RD in Trendmicro