> For the complete documentation index, see [llms.txt](https://docs.rhinofcp.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.rhinofcp.com/getting-started/quick-start-guide/pushing-containers-to-the-ecr.md).

# Pushing Containers to the ECR

## Prerequisites

Complete the following before you begin.

* Before starting, complete all steps in [FCP Client Installation and Environment Configuration](/getting-started/quick-start-guide/fcp-client-installation-and-environment-configuration.md).  This will ensure that your dependencies have been installed, your AWS CLI has been configured and you are able to connect to your specific ECR workspace.
* Make sure that the docker daemon has been started as a prerequisite to pushing containers to the ECR.
* Make note of the following:
  * For both methods below, the variable **myapplication** is the name you are assigning your container. It can be whatever you choose to make it, but it must be unique to each container that is pushed to your ECR. We recommend adding some kind of versioning to your container name.
  * Your **workgroup\_repository\_name** can be found within your user profile. Read [Viewing and Adjusting Your Settings](/settings/viewing-and-adjusting-your-settings.md) for more details.

## Production Environment URIs

For users in our production environments pushing container images to their workgroup's repo on Rhino FCP, here are the URIs they need to use for AWS and GCP.

{% tabs %}
{% tab title="AWS" %}
In environments using a Rhino Orchestrator on AWS (currently [dashboard.rhinohealth.com](http://dashboard.rhinohealth.com/)):

```
{AWS_ACCOUNT_ID}.dkr.ecr.{AWS_REGION}.amazonaws.com/{WORKGROUP_REPO_NAME}:{TAG}
```

{% endtab %}

{% tab title="GCP" %}
In environments using a Rhino Orchestrator on GCP (currently [dashboard.rhinofcp.com](http://dashboard.rhinofcp.com/)):

```
{GCP_REGION}-docker.pkg.dev/{GCP_PROJECT_ID}/{WORKGROUP_REPO_NAME}/images:{TAG}
```

{% endtab %}
{% endtabs %}

### About Variables

Here are some details about the variables in the above templates:

* AWS\_ACCOUNT\_ID: Our production AWS account ID: `865551847959`
* AWS\_REGION: Our production AWS resources are in: `us-east-1`
* GCP\_REGION: Our production GCP resources are in: `europe-west4`
* GCP\_PROJECT\_ID: Our production GCP project ID: `rhino-health-prod`
* WORKGROUP\_REPO\_NAME: Configured for each workgroup in our database, and available for users in our dashboard under "Settings" -> "Containers & Artifacts".
* TAG: Arbitrarily chosen by users to label each container image. Unique in each workgroup's repo, and immutable, i.e. after pushing one container image with a given tag, no other may be pushed with that tag.

### Examples

The following examples show how to build and push containers, and also list and pull images.

{% tabs %}
{% tab title="Using the Rhino Util docker-push.sh" %}
The [docker-push.sh](https://github.com/RhinoHealth/user-resources/blob/main/rhino-utils/docker-push.sh) script can be found in the [user-resources](https://github.com/RhinoHealth/user-resources/) GitHub repository under the rhino\_utils folder. Using a terminal or command line navigate to the directory where your Dockerfile and other relevant files are found. Copy the docker-push.sh script into that folder and make it executable by running

```bash
chmod +x docker-push.sh
```

cd to the directory where your Dockerfile and other relevant code files are found.

```bash
./docker-push.sh <workgroup_repository_name> myapplication
```

{% endtab %}

{% tab title="Using Only Docker" %}
cd to the directory where your Dockerfile and other relevant files are found.

#### Build Container Command

```bash
DOCKER_BUILDKIT=1 docker build --platform linux/amd64 -t 865551847959.dkr.ecr.us-east-1.amazonaws.com/<workgroup_repository_name>:myapplication .
```

**Note: the period at the end of the above build command.**

#### Push Container Command

```bash
docker push 865551847959.dkr.ecr.us-east-1.amazonaws.com/<workgroup_repository_name>:myapplication
```

{% endtab %}
{% endtabs %}

#### List Local Images Example

```auto
> docker images 865551847959.dkr.ecr.us-east-1.amazonaws.com/<workgroup_repository_name>
```

#### List Remote Images Example

```auto
> aws ecr list-images --registry-id 865551847959 --repository-name <workgroup_repository_name>
```

#### Pull a Container Image from a Remote Repository Example

```auto
> docker pull 865551847959.dkr.ecr.us-east-1.amazonaws.com/<workgroup_repository_name>:myapplication
```
