Docker Hub Images

Deploying a Docker Image from Docker Hub

Flightcontrol supports deploying pre-built container images from three different image registries: Docker Hub (opens in a new tab), GitHub Container Registry (opens in a new tab) and AWS Elastic Container Registry (ECR) (opens in a new tab). This guide will walk you through deploying a Docker image from Docker Hub.

We will create an access token for Docker Hub so that you can give Flightcontrol read-only access to your Docker Hub account. Then we will configure a web application service that deploys an image from your Docker Hub image registry to AWS Elastic Container Service (ECS). Last, we'll discuss how to automatically deploy changes to your application when you push a new image to Docker Hub.

Prerequisites

You'll need the following before you begin:

Creating a Docker Hub Access Token

Flightcontrol needs to authenticate to your Docker Hub account to pull your Docker image. While you could use your username and password, we discourage that, and recommend creating a read-only access token for Flightcontrol instead.

You can use the access token in place of your password - your username will remain the same.

Let's go through the necessary steps.

Login to Docker Hub

Login to Docker Hub (opens in a new tab) and click on your profile picture in the top right corner. Then click on Account Settings.

Create a New Access Token

Click on Security in the left sidebar, then click on New Access Token.

Security Tab on Docker Hub Account Settings

Choose the Name and Permissions

Give your access token a name, and choose the Read-only access permissions. Then click on the Generate button.

New Access Token dialog

Save the Access Token

This will be the only time you see the access token, so copy and save the access token somewhere convenient, or leave the window up until you need to use it.

Adding a Docker Hub Image Registry to Flightcontrol

Let's use our access token to setup an image registry on Flightcontrol.

Open Organization settings from the button in the top right corner of the Flightcontrol dashboard.

In the sidebar that opens up, choose the Image registries tab.

Add an Image Registry

Click the Add image registry button to add a new image registry.

Add an Image Registry to Flightcontrol

Choose the Docker Hub Registry Type

When you add a new image registry, you'll need to choose the registry type. We'll pick Docker Hub.

New Image Registry page on Flightcontrol filled in with Docker Hub information

Add your Docker Hub Username and Access Token

After choosing the Docker Hub registry type, you'll need to enter your Docker Hub username and access token. The access token goes into the password field.

Because you configured a read-only access token, Flightcontrol will be able to pull images from your Docker Hub account.

Click the Add registry button to save your Docker Hub image registry.

After connecting your Docker Hub image registry to Flightcontrol, you can deploy your Docker images to AWS ECS.

Creating a Flightcontrol Project

Now, let's create a Flightcontrol project to deploy the Docker images from your Docker Hub image registry.

Create a new project in the Flightcontrol dashboard and choose a GitHub source code repository to use. You can choose a public or private repository. While Flightcontrol won't use the source code in the repository to produce a build, you can use a flightcontrol.json file in the repository to configure your project.

After choosing a repository, you'll be able to configure your project, similar to the following screenshot:

Configuring a project in the dashboard

Change the project name if desired, pick an AWS account, and then choose which AWS region to deploy to.

Click Next to continue.

Choosing a Preset

Flightcontrol has a number of presets that you can use to configure your project. Presets are a convenient way to configure your project, and you can always change the configuration later.

Select a Preset dialog box in Flightcontrol

For this guide, we'll use the Build your own option instead of one of the presets.

The next screen will let you add services to your project. Note - we'll be using the Flightcontrol dashboard to configure our project, instead of using a flightcontrol.json file in our source code repository.

Click the Add service button to add a service to your project.

Add your services to Flightcontrol, with the picker

From the available list of services, choose the Server service type. This will add a web server service to your project.

Configuring the Web Server Service

After the Web Server service is added to your project, you'll need to configure it. The default build type is Nixpacks, so we will need to change the build type to Pull from image registry.

Configuring a Web Server service

Once we change the build type, a new set of configuration options will appear. Choose the Docker Hub image registry you created earlier, and enter the name of the Docker image you want to deploy. Typically, you will want to use the latest tag for your image, but you can use any tag here.

You also may provide a descriptive name for your web server service, if the default name isn't suitable.

Click the Add service button to continue, and go back to the project configuration screen.

Creating the Project

Once you've added the web server service to your project, go ahead and add any additional services, such as a relational database or a Redis server. You can also configure environment variables for your services.

Create your project with the Create Project button.

Flightcontrol will pull your Docker image from Docker Hub, and then deploy it to AWS ECS.

Right now, this is a manual process, but you may want to automate this. After a successful build that pushes a new image to Docker Hub, your build pipeline would trigger a deployment with Flightcontrol.

Automating the Deployment Process

Flightcontrol supports automatically deploying your application when you push a new image to Docker Hub. To do this, you'll need to create a deploy hook in Flightcontrol, and then trigger the deploy hook when a new image is pushed.

Follow our guide on Automating Docker Deployments to learn how to create a deploy hook and then trigger it from your continuous integration (CI) pipeline.

Conclusion

Using these tools, you can automate your continuous delivery (CD) to deploy your Docker images to AWS ECS with Flightcontrol.

You can use the build pipeline you already have to build and push your Docker images to Docker Hub, and then trigger a deployment with Flightcontrol.