CLOVER🍀

That was when it all began.

Docker Compose 1.13.0から「scale」が非推奨になり、「up --scale」になったという話

Docker Composeで、「scale」コマンドを使用すると起動しているコンテナをスケールさせることができます。

docker-compose scale

こちらが、実行すると警告されるようになったという話。

例えば、こういうdocker-compose.ymlを用意して
docker-compose.yml

version: "3.3"
services:
  infinispan:
    image: jboss/infinispan-server:9.0.3.Final

起動。

$ docker-compose up

「scale」で、コンテナをスケールさせます。

$ docker-compose scale infinispan=3
WARNING: The scale command is deprecated. Use the up command with the --scale flag instead.
Starting ispn_infinispan_1 ... done
Creating ispn_infinispan_2 ... 
Creating ispn_infinispan_3 ... 
Creating ispn_infinispan_2 ... done
Creating ispn_infinispan_3 ... done

すると、スケールするにはするのですが、よくよく見ると警告されています。

WARNING: The scale command is deprecated. Use the up command with the --scale flag instead.

確かに、「scale」コマンド上でもdeprecatedになっています。

Note: This command is deprecated. Use the up command with the --scale flag instead.

https://docs.docker.com/compose/reference/scale/

「--scale」を使え、と。

で、Release Notesを見てみると、1.13.0から「scale」コマンドが非推奨となり、「--scale」オプションになったようです。

Docker Compose release notes

「--scale」は、「up」コマンドのオプションになります。

docker-compose up

試してみましょう。コンテナを3つにして起動してみます。

$ docker-compose up --scale infinispan=3
Creating ispn_infinispan_1 ... 
Creating ispn_infinispan_2 ... 
Creating ispn_infinispan_3 ... 
Creating ispn_infinispan_1 ... done
Creating ispn_infinispan_2 ... done
Creating ispn_infinispan_3 ... done

〜省略〜

確かに、3つ起動しました。

これは便利ですね、覚えておきましょう。