🐳
Docker Composeでjson: cannot unmarshal array into Go value of typeが出た
いつも通りにdocker compose up -d
と打ったら、謎のエラーが発生し調べてもいまいち出てこなかった。
json: cannot unmarshal array into Go value of type types.ImageInspect
結論
image
とbuild
を間違えてた
version: "3"
services:
app:
image: . # ← buildなのにimageとなってしまっている
restart: always
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
build
に直したら普通に動いた。
Goの構造体エラーが出たらキー名をしっかりと確認しましょう。今回の場合types.ImageInspect
となってるのでimage
関連だとわかりやすいかもれしれないです(あとから気づいた)
危うくハマるところだった。(今回はコードが短かったのもある)
Discussion