내용으로 건너뛰기

Lightsail push error – image tag already exists and is immutable

0

Hi,

I'm encountering this error when pushing a Docker image to my Lightsail container service (grati): "error from registry: The image tag '...-...' already exists in the 'sr' repository and cannot be overwritten because the tag is immutable."

Steps I’ve taken: Rebuilt image with --no-cache Used unique --label values for each push

Example command: aws lightsail push-container-image
--service-name grati
--label client-01
--image grati/client

I still get the same error. How can I ensure new images push successfully without hitting the immutable tag error?

thank you!

질문됨 6달 전232회 조회
5개 답변
2
수락된 답변

Hi,

This could happen if you have docker's containerd image feature enabled. In case you have it enabled, you could try the work around mentioned in this GitHub issue: https://github.com/aws/lightsailctl/issues/95#issuecomment-2491793548.

AWS
답변함 6달 전
AWS
전문가
검토됨 6달 전
  • wo-hooo, looks like it helped! thank you

1

The error you're encountering is due to the immutable tag setting in your Lightsail container service. This setting prevents overwriting existing image tags, which is a security feature to ensure version consistency and prevent potential attacks.

To resolve this issue and successfully push new images, you can try the following approaches:

  1. Use unique tags: Instead of using a static tag, consider using unique tags for each new image version. You could incorporate a timestamp, build number, or git commit hash into your tag. For example:

    aws lightsail push-container-image
    --service-name grati
    --label client-01-$(date +%Y%m%d%H%M%S)
    --image grati/client

  2. Update your workflow: Ensure that you're using a new, unique label each time you push an image. The label is part of the image name generated by Lightsail, so using a new label will create a new image rather than trying to overwrite an existing one.

  3. Delete old images: If you're running into storage limits, you may need to delete old, unused images before pushing new ones. However, be cautious not to delete images that are currently in use by your deployments.

  4. Review your container service settings: Check if there's an option to change the tag mutability setting for your Lightsail container service. However, keeping tags immutable is generally recommended for security reasons.

Remember, using immutable tags is a best practice in container management. It ensures that each image version remains distinct and prevents accidental or malicious overwriting of existing images. By adapting your workflow to use unique labels or tags for each push, you can maintain this security feature while still updating your images as needed.
Sources
Push, view, and delete container images for a Lightsail container service - Amazon Lightsail
Task and container security - Amazon Elastic Container Service

답변함 6달 전
전문가
검토됨 6달 전
0

Thank you, but despite using a unique label with a timestamp: aws lightsail push-container-image
--service-name grati
--label client-$(date +%Y%m%d%H%M%S)
--image grati/client

I still encountered the same error: error from registry: The image tag '[...]' already exists in the 'sr' repository and cannot be overwritten because the tag is immutable.

It seems that even with a unique label it doesn't work. I’d appreciate any guidance on how to proceed!

답변함 6달 전
0

Hello.

I wasn't able to reproduce the error in my AWS account, but how about changing the container image tag as shown below before pushing?

docker tag grati/client:latest grati/client:2
전문가
답변함 6달 전
0

Hi Riku,

Thank you for the suggestion. I tried it, but unfortunately, I'm still encountering the same error

답변함 6달 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

관련 콘텐츠