Skip to content
Branch: master
Find file History

Latest commit

Fetching latest commit…
Cannot retrieve the latest commit at this time.

Files

Permalink
Type Name Latest commit message Commit time
..
Failed to load latest commit information.
README.md
demo_server.py
docker-compose.yml
scale.sh

README.md

docker-compose scale 传参

本示例, 展示在 docker-compose up --scale 场景下, 如何向容器传递当前容器序号。

执行:

docker-compose down
chmod +x ./scale.sh 
./scale.sh

结果:

demo.log 文件中, 展示如下结果:

server-1
server-2
server-3
server-4
server-5
server-6
server-7
server-8
server-9
server-10

结果表明:

  • 每个容器只会执行一次
  • 每个容器可根据 $HOSTNAME 获知容器的序号
You can’t perform that action at this time.