Manage Lightsail container service images - Amazon Lightsail

Manage Lightsail container service images

When you create a deployment in your Amazon Lightsail container service, you must specify a source container image for each container entry. You can use images from a public registry, such as Amazon ECR Public Gallery, or you can use images that you create on your local machine. In this guide, we show you how to push container images from your local machine to your Lightsail container service. For more information about creating container images, see Create container service images.

Contents

Prerequisites

Complete the following prerequisites before you get started with pushing your container images to your container service:

Push container images from your local machine to your container service

Complete the following procedure to push your container images to your container service.

  1. Open a command prompt or terminal window.

  2. In the command prompt or terminal window, enter the following command to view the Docker images that are currently on your local machine.

    docker images
  3. In the result, locate the name (repository name) and tag of the container image that you want to push to your container service. Make a note of it because you will need it in the next step.

    
            Docker container images on a local machine
  4. Enter the following command to push the container image on your local machine to your container service.

    aws lightsail push-container-image --region <Region> --service-name <ContainerServiceName> --label <ContainerImageLabel> --image <LocalContainerImageName>:<ImageTag>

    In the command, replace:

    • <Region> with the AWS Region in which your container service was created.

    • <ContainerServiceName> with the name of your container service.

    • <ContainerImageLabel> with the label that you want to give your container image when it's stored on your container service. Specify a descriptive label that you can use to track the different versions of your registered container images.

      The label will be part of the container image name generated by your container service. For example, if your container service name is container-service-1, the container image label is mystaticsite, and this is the first version of the container image you're pushing, then the image name generated by your container service will be :container-service-1.mystaticsite.1.

    • <LocalContainerImageName> with the name of the container image that you want to push to your container service. You obtained the container image name in the previous step of this procedure.

    • <ImageTag> with the tag of the container image that you want to push to your container service. You obtained the container image tag in the previous step of this procedure.

    Example:

    aws lightsail push-container-image --region us-west-2 --service-name myservice --label mystaticwebsite --image mystaticwebsite:v2

    You should see a result similar to the following example, which confirms that your container image was pushed to your container service.

    
            Docker container image pushed to a Lightsail container service

    Refer to the following View container images stored on your container service section of this guide to view your pushed container image in your container service on the Lightsail console.

View container images stored on your container service

Complete the following procedure to view container images that were pushed, and are being stored, on your container service.

  1. Sign in to the Lightsail console.

  2. On the Lightsail home page, choose the Containers tab.

  3. Choose the name of the container service for which you want to view the stored container images.

  4. On the container service management page, choose the Images tab.

    Note

    The Images tab is not displayed if you have not pushed images to your container service. To display the images tab for your container service you must first push container images to your service.

    The Images page lists the container images that were pushed to your container service, and are currently being stored on your service. Container images that are being used in a current deployment cannot be deleted and are listed with a grayed-out delete icon.

    
            The stored images page of the Lightsail console

    You can create deployments using container images stored on your service. For more information, see Creating and managing deployments for your Amazon Lightsail container services.

Delete container images stored on your container service

Complete the following procedure to delete container images that were pushed, and are being stored, on your container service.

  1. Sign in to the Lightsail console.

  2. On the Lightsail home page, choose the Containers tab.

  3. Choose the name of the container service for which you want to view the current deployment.

  4. On the container service management page, choose the Images tab.

    Note

    The Images tab is not displayed if you have not pushed images to your container service. To display the images tab for your container service you must first push container images to your service.

  5. Find the container image you want to delete, and choose the delete (trash bin) icon.

    Note

    Container images that are being used in a current deployment cannot be deleted and their delete icons are grayed-out.

  6. In the confirmation prompt that appears, choose Yes, delete to confirm that you want to permanently delete the stored image.

    Your stored container image is immediately deleted from your container service.