In a recent articleseries, I explained how to use Amazon Web Services' EC2 Container Service (ECS) to deploy a very simple application container. However, while deploying a sample application is a good start, it's something that you are unlikely to do in the real world.

If you are planning to use containers in production, then you will need to know how to push a Docker image to AWS. In this article, I will show you how it's done.

Before I get started, I need to mention a couple of prerequisites. First, I am assuming that you actually have a container image that you want to push to AWS. Second, I am assuming that you have both Docker and the AWS Command Line Environment (CLI) installed on your local environment.

So with that said, let's get started.

The first thing that you need to know about the process of pushing container images to AWS is that container images are stored in a container repository within the AWS cloud. AWS lets you use the GUI to create a container repository, but adding images to that repository requires you to delve into the command line.

To create a container repository, log in to the AWS console, and choose the EC2 Container Service option from the list of services. This option is located in the Compute section. This will cause AWS to open the Clusters dashboard. If you look at Figure 1, you will notice that this dashboard contains a Repositories tab, located on the left side of the screen. Go ahead and click on Repositories.

[Click on image for larger view.]Figure 1: Click on the Repositories link.

At this point, you will be taken to the Repositories screen, which you can see in Figure 2. As you can see, this screen is pretty simple. It lists any existing repositories and contains buttons that you can use to create or delete repositories.

[Click on image for larger view.]Figure 2: This is the Repositories screen.

Go ahead and click on the button to create a repository. Upon doing so, you will be taken to a screen like the one shown in Figure 3. Now, just enter a name for the repository that you want to create and click the Next Step button. Upon doing so, the repository will be created.

[Click on image for larger view.]Figure 3: Enter a name for the repository that you want to create and click the Next Step button.

Before I move on, there are a couple of things that I want to point out about this screen. First, notice that AWS lists the repository URI. After you type the repository name, it is a good idea to write down the URI before you click Next Step.

The other thing worth noting is that according to the screen, the repository owner (you) has access to the repository by default, but you will need to grant access to anyone else who needs it.

At this point, the container repository is created. Authenticating your Docker client into this registry is a little bit tricky, but AWS does provide some instructions on the next screen. The first step in the process is figuring out the command that is used to log in. AWS provides you with a command that you can use to retrieve the log-in command. It looks similar to this:

aws ecr get-login --no-include-email --region us-west-2

Next, you will need to log in. If you are on a Linux system, then you will need to run the command that was returned by the previous command. If you are on a Windows system, then AWS provides a PowerShell command that you can use instead. The example PowerShell command that AWS provides is:

If you would like to see what these instructions look like in their entirety, then check out Figure 4. This is the screen that AWS displays after you create a repository.

[Click on image for larger view.]Figure 4: AWS displays these instructions after you create a container repository.

As you can see, the process of setting up a repository and uploading a container image is relatively easy. If you need help, though, AWS provides detailed instructions here.

About the Author

Brien Posey is a seven time Microsoft MVP with over two decades of IT experience. As a freelance writer, Posey has written many thousands of articles and written or contributed to several dozen books on a wide variety of IT topics. Prior to going freelance, Posey was a CIO for a national chain of hospitals and healthcare facilities. He has also served as a network administrator for some of the country's largest insurance companies and for the Department of Defense at Fort Knox. When He isn't busy writing, Brien Posey enjoys exotic travel, scuba diving, and racing his Cigarette boat. You can visit his personal Web site at: www.brienposey.com.