Fly Friday - Flyctl and Ports

TL;DR: The -p flag is used with flyctl apps create when you create a Fly app for the first time. Setting -p with a numeric value automatically sets the internal port of the generated fly.toml configuration file. The internal port is the port your a

Dj Walker-Morgan
2 min readbeginner
--
View Original

Overview

The article discusses the new '-p' option for the Flyctl command-line tool, which simplifies the process of creating a Fly app by allowing users to set the internal port directly during app creation. This feature aims to streamline workflows for users deploying prebuilt Docker images on Fly.

What You'll Learn

1

How to use the '-p' flag with Flyctl to set the internal port during app creation

2

Why the internal port is important for application communication

3

When to utilize prebuilt Docker images with Fly and adjust internal port settings

Key Questions Answered

What does the '-p' flag do in Flyctl?
The '-p' flag in Flyctl is used to set the internal port of a Fly app during its creation. By providing a numeric value with this flag, users can automatically configure the internal port in the generated fly.toml file, eliminating the need for manual edits.
What is the default internal port for Fly apps?
The default internal port for Fly apps is set to 8080. This is the port used by applications to communicate with the outside world unless specified otherwise using the '-p' flag.
Why was the '-p' flag introduced in Flyctl?
The '-p' flag was introduced to simplify the workflow for users who create Fly apps using prebuilt Docker images, as these users often need to change the internal port setting. This feature reduces the steps required from creating an app to editing the fly.toml file.

Technologies & Tools

Some links below are affiliate links. We may earn a commission if you make a purchase.

Tool
Flyctl
Command-line tool for managing Fly applications, including creating apps with specific configurations.
Tool
Docker
Used for deploying prebuilt images that may require custom internal port settings.

Key Actionable Insights

1
Utilize the '-p' flag when creating a Fly app to streamline your deployment process.
This flag allows you to set the internal port directly, which is especially useful when working with prebuilt Docker images that may not use the default port.
2
Familiarize yourself with the fly.toml configuration file to understand how internal ports affect application behavior.
Knowing how to configure this file can help you troubleshoot issues related to application communication and deployment.

Common Pitfalls

1
Failing to set the internal port correctly when using prebuilt Docker images can lead to communication issues.
This often happens because users overlook the need to adjust the internal port in the fly.toml file, which can result in applications not functioning as expected.