Creating an NGINX Docker Image and Register with the AWS Elastic Container Registry (ECR)

Register with Elastic Container Registry (ECR)

Docker is an open source containerization platform. It enables developers to package applications into containers — standardized executable components combining application source code with the operating system (OS) libraries and dependencies required to run code in any environment.

In order to complete this lesson you will need the following:

  • Docker Hub Account
  • AWS Account
  • Install Docker
  • Install AWS CLI

After installing Docker, you will need to create two files.

Two files to create dockefile and index.html

The first being the index.html file which is going to display the my nginx page with the time and date the container was built.

index.html which has the message to displayed as well as time and date.

The second being the Dockerfile which; is a text document that contains all the commands a user could call on the command line to assemble an image. Using docker build users can create an automated build that executes several command-line instructions in succession.

Dockerfile referencing the index.html file

A Dockerfile is a text document that contains all the commands a user could call on the command line to assemble an image. Using docker build users can create an automated build that executes several command-line instructions in succession.

Command must be run to start docker
Run hello-world to ensure docker has started error free

Now I will build the docker by running the docker build -t my-nginx.

Docker build command above
Docker build successful
Docker image list above built previously as evident by number of day ago created.

Deploy container on port 8080.

Container successfully deployed on port 8080

Next, I will save the code to Elastic Container Registry. After installing the AWS CLI assuming you know how this is completed. You will need to call on your user credentials with the following command:

aws sts get-caller-identity retrieves account for current user.

Create new repository below:

aws ecr create — repository-name my- nginx

nginx repo listed above

Finally we will view the webpage.

Complete webpage accessible and the time and date for the creation of the container is present.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store