Get container name inside the docker container
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"