조금 복잡하긴 하지만… 이렇게 하면 작동할 것 같습니다:
# First, make sure you've got the latest base image locally
# 먼저, 로컬에 최신 베이스 이미지가 있는지 확인하세요
docker pull discourse/mail-receiver:release
# Get the top layer of the base image
# 베이스 이미지의 최상위 레이어를 가져옵니다
BASE_IMAGE_HASH=$(docker history discourse/mail-receiver:release -q | head -n 1)
# Get the layers of the **running** version
# **실행 중**인 버전의 레이어를 가져옵니다
RUNNING_IMAGE_HASH=$(docker container inspect mail-receiver -f "{{.Image}}")
RUNNING_IMAGE_LAYERS=$(docker history $RUNNING_IMAGE_HASH -q)
# Check if the running image layers include the current base image:
# 실행 중인 이미지 레이어에 현재 베이스 이미지가 포함되어 있는지 확인합니다:
[[ "$RUNNING_IMAGE_LAYERS" == *"$BASE_IMAGE_HASH"* ]] && echo "Up to date"
이 명령은 최신 상태라면 "Up to date"를 출력합니다. 그렇지 않으면 마지막 줄은 아무것도 출력하지 않고, 0이 아닌 상태로 종료됩니다.