Build and Push wordpress project to AWS ECR
Tags: aws, docker, ecr
Published: 2020-02-07 01:01:46

---
title: Build and Push wordpress project to AWS ECR
published: true
date: 2019-12-11 02:06:18 UTC
tags: AWS,Docker,ECR
cover_image: https://s3-ap-southeast-2.amazonaws.com/sal-blog/wp-content/uploads/2019/12/26130911/Wordpress-Series.jpeg
canonical_url: 
---

> **This article is the continuation of [WordPress with Docker, AWS (ECS, Code Pipeline, Load Balancer, RDS, EFS) Complete Series](https://dev.to/saluminati/high-traffic-wordpress-website-with-docker-aws-ecs-code-pipeline-load-balancer-rds-efs-complete-series-43id/). For better understating, please start from the beginning of the series.**

# Build and Tag WordPress Docker project

As we have already set up our WordPress Docker project in [Dockerize WordPress with themes, plugins and common configuration](https://dev.to/saluminati/dockerize-wordpress-with-themes-plugins-and-common-configuration-2am4) article. Its time to Tag and push our WordPress project to AWS ECR.

You can also download the Docker WordPress project used in this tutorial series from [https://github.com/saluminati/personal-docker-blog](https://github.com/saluminati/personal-docker-blog)

Go to you wordpress project root directory and execute the following commands:

```shell

docker build .
```

You should see something like that on the console

[![](https://s3-ap-southeast-2.amazonaws.com/sal-blog/wp-content/uploads/2019/12/24062939/Screen-Shot-2019-12-11-at-12.39.25-pm-1.png)](https://s3-ap-southeast-2.amazonaws.com/sal-blog/wp-content/uploads/2019/12/24062939/Screen-Shot-2019-12-11-at-12.39.25-pm-1.png)

Now we need to tag the build, for that, please run the following command:

```shell

docker images
```

[![](https://s3-ap-southeast-2.amazonaws.com/sal-blog/wp-content/uploads/2019/12/24063028/Screen-Shot-2019-12-11-at-12.41.41-pm-1.png)](https://s3-ap-southeast-2.amazonaws.com/sal-blog/wp-content/uploads/2019/12/24063028/Screen-Shot-2019-12-11-at-12.41.41-pm-1.png)

```shell
# for you: replace --image-- with your image_id
# replace salman-docker-blog with the name your prefer

docker tag --image-- salman-docker-blog:v0.0.1
```

Run docker images command and you should see your image tagged properly

[![](https://s3-ap-southeast-2.amazonaws.com/sal-blog/wp-content/uploads/2019/12/24063103/Screen-Shot-2019-12-11-at-12.44.46-pm-1024x89.png)](https://s3-ap-southeast-2.amazonaws.com/sal-blog/wp-content/uploads/2019/12/24063103/Screen-Shot-2019-12-11-at-12.44.46-pm-1024x89.png)

# Push the Docker build to ECR

Please follow this [link](https://docs.aws.amazon.com/cli/latest/userguide/install-cliv1.html) to install AWS cli on your local machine.

Once its installed, you should be able to run the following command on your console to configure AWS IAM User credentials you have recently downloaded as a CSV file.

```shell
aws configure
```

Please use the credentials from the CSV file you have downloaded in [Create IAM (User, Roles and Policies)](https://dev.to/saluminati/create-iam-user-roles-and-policies-pmm/) article.

It will ask for AWS Key ID, Secret Key and AWS region. Please use the appropriate region.

More information about AWS regions are available [here](https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/Concepts.RegionsAndAvailabilityZones.html)

## Create ECR Repository

In this section, we will create a ECR repository on AWS and push our docker build by using AWS cli.

Let’s do this !

Go to AWS service tab and search ECR. Click on create repository.

[![](https://s3-ap-southeast-2.amazonaws.com/sal-blog/wp-content/uploads/2019/12/24064708/Screenshot_2019-12-11-Amazon-ECR-1.png)](https://s3-ap-southeast-2.amazonaws.com/sal-blog/wp-content/uploads/2019/12/24064708/Screenshot_2019-12-11-Amazon-ECR-1.png)

Make sure you enable Tag Immutability.

[![](https://s3-ap-southeast-2.amazonaws.com/sal-blog/wp-content/uploads/2019/12/24064746/Screenshot_2019-12-11-Amazon-ECR1-2.png)](https://s3-ap-southeast-2.amazonaws.com/sal-blog/wp-content/uploads/2019/12/24064746/Screenshot_2019-12-11-Amazon-ECR1-2.png)

Copy the repository URI, we will use it in the next step.

## Push to AWS ECR !

Finally !!!! we are now ready to push our Docker build to Amazon AWS

Go to your console and run the following commands:

```shell
docker build . -t salman-docker-blog

docker tag salman-docker-blog:latest <repouri>:v1.0.0</repouri>
```

Please replace the <RepoURI> with your ECR repository you have created earlier.

Now your docker image is tagged, time to push it. For that, you will need to run the following command on console to login to AWS ECR service.

```shell
aws ecr get-login --no-include-email
```

This command will print a long string on your console screen. Please copy that long string and paste it to your console again. That will log you in to ECR Service. Once you paste the code and hit enter, you should be able to see **Login Succeeded** message.

Now to final command

```shell
docker push <repouri>:v1.0.0</repouri>
```

When you will click on your repository in AWS ECR. You will be able to see that version 1.0.0 is being pushed.

[![](https://s3-ap-southeast-2.amazonaws.com/sal-blog/wp-content/uploads/2019/12/24064815/Screenshot_2019-12-11-Amazon-ECR2-1024x332.png)](https://s3-ap-southeast-2.amazonaws.com/sal-blog/wp-content/uploads/2019/12/24064815/Screenshot_2019-12-11-Amazon-ECR2-1024x332.png)

#### Previous

**[Create AWS EFS (Elastic File System) Plugin storage for WordPress behind Load Balancer](https://dev.to/saluminati/create-aws-efs-elastic-file-system-plugin-storage-for-wordpress-behind-load-balancer-3hm0/)**

#### Next

**[Create Load Balancer for WordPress website](https://dev.to/saluminati/create-load-balancer-for-wordpress-website-4f8m/)**