やりたいこと
RaspberryPi4にDockerをインストールします。デフォルトだと、/var/lib/dockerがdockerが使用するデータのルートディレクトリになってますが、これを適当な場所に変更します。
手順
1.dockerをインストールする
sudo apt install docker.io
2.dockerのデータルートを設定
以下のファイルを作成します。ファイルが存在しないので新規作成です。
/etc/docker/daemon.json
{
"data-root": "/data/app/main/docker"
}
3.dockerを再起動します
sudo systemctl restart docker.service
ちゃんと/data/app/main/dockerにそれっぽいファイルができていることを確認します。
sudo ls -l /data/app/main/docker
4./var/lib/docker/は不要なので削除します
sudo rm -rf /var/lib/docker
5.piユーザのサブグループにdockerグループを追加します
sudo usermod -aG docker pi