Connecting to containers
For Amazon GameLift Servers container fleets, you can access game server containers running on a fleet instance. Use container access to troubleshoot game sessions, inspect logs, and debug runtime issues.
Connecting to a container
Connect to the fleet instance. For instructions, see Connecting to fleet instances.
To connect to a container
-
Run the following command to list running containers on the instance:
sudo docker psThe output lists all containers running on the instance, including game server containers and internal Amazon GameLift Servers containers. Look for containers with your game server image to identify the game server containers.
Example output:
CONTAINER ID IMAGE COMMAND CREATED STATUS b9676e9489f5 game-server-container "/bin/sh -c ./$GAME_âĶ" 2 days ago Up 2 days 1d1c8443efe2 support-container "/bin/sh -c ./$SUPPOâĶ" 2 days ago Up 2 days -
To connect to a game server container, use the container short ID from the
CONTAINER IDcolumn. This gives you full read and write access to the container filesystem.sudo docker exec -itcontainer-short-idsh
Connecting to a container through the console
You can connect to game server containers from the Amazon GameLift Servers console using Amazon EC2 Systems Manager (SSM). This method provides secure access without requiring additional setup or credential management. You can connect to a container from either the Computes tab or the Game sessions tab on the fleet details page.
To connect to a container through the console
-
In the Amazon GameLift Servers console, choose Managed containers from the navigation pane, and then Fleets.
-
Choose the fleet ID that contains the container or game session you want to access.
-
On the fleet details page, choose one of the following tabs:
Computes â Lists the containers running on the fleet. Select the container you want to connect to.
Game sessions â Lists the game sessions for the fleet. Select the game session to connect to the container hosting it.
-
Choose Connect. Copy the command displayed to connect to the container, then choose Connect again.
-
In the connection dialog, choose Run to create a new SSM session. Your session is authenticated through AWS Key Management Service (AWS KMS), and a terminal opens in your browser. It might take a few moments for the session to start and the terminal to open.
-
Once you have connected to the instance, paste the docker command from step 4 and execute it on the instance to access the container.
Connecting to container hosting a game session
To connect to the game server container hosting a specific game session, follow these steps.
To connect to the container hosting a game session
-
Get the compute name. Call describe-game-sessions to get the
ComputeNamefor the game session.Request
aws gamelift describe-game-sessions \ --fleet-idfleet-2222bbbb-33cc-44dd-55ee-6666ffff77aa\ --game-session-idarn:aws:gamelift:us-west-2::gamesession/fleet-2222bbbb-33cc-44dd-55ee-6666ffff77aa/gs-1111aaaa-2222-3333-4444-5555bbbb66ccResponse
{ "GameSessions": [ { "GameSessionId": "arn:aws:gamelift:us-west-2::gamesession/fleet-2222bbbb-33cc-44dd-55ee-6666ffff77aa/gs-1111aaaa-2222-3333-4444-5555bbbb66cc", "FleetId": "fleet-2222bbbb-33cc-44dd-55ee-6666ffff77aa", "ComputeName": "62c5ff7f7a9a445d84877074c80aeafc", "Status": "ACTIVE", . . . } ] }Note the
ComputeNamevalue from the response (for example,62c5ff7f7a9a445d84877074c80aeafc). -
Get compute access and container attributes. Call get-compute-access with the fleet ID and compute name.
The response includes the following fields:
ContainerIdentifiersâ TheContainerNameandContainerRuntimeIdfor each container.GameServerContainerGroupDefinitionArnâ The ARN of the container group definition.Credentialsâ Temporary credentials to connect to the instance.
Request
aws gamelift get-compute-access \ --fleet-idfleet-2222bbbb-33cc-44dd-55ee-6666ffff77aa\ --compute-name62c5ff7f7a9a445d84877074c80aeafcResponse
{ "ComputeName": "62c5ff7f7a9a445d84877074c80aeafc", "ContainerIdentifiers": [ { "ContainerName": "game-server", "ContainerRuntimeId": "02accb92cd9bef3373300e7151d5c2b3dcca3b06eff1bb4e345085fc008d4678" } ], "Credentials": { "AccessKeyId": "ASIAIOSFODNN7EXAMPLE", "SecretAccessKey": "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY", "SessionToken": "AQoDYXdzEJr...<remainder of session token>" }, "FleetId": "fleet-2222bbbb-33cc-44dd-55ee-6666ffff77aa", "GameServerContainerGroupDefinitionArn": "arn:aws:gamelift:us-west-2::containergroupdefinition/MyGameServerGroup" } -
Connect to the instance. Use the credentials from step 2 to connect to the fleet instance. For detailed instructions, see Connecting to fleet instances.
-
Find the game server container name. Call describe-container-group-definition using the
GameServerContainerGroupDefinitionArnfrom step 2 to identify the game server container name.Request
aws gamelift describe-container-group-definition \ --namearn:aws:gamelift:us-west-2::containergroupdefinition/MyGameServerGroupResponse
{ "ContainerGroupDefinition": { "ContainerGroupDefinitionArn": "arn:aws:gamelift:us-west-2:123456789012:containergroupdefinition/MyGameServerGroup:3", "Name": "MyGameServerGroup", "ContainerGroupType": "GAME_SERVER", "GameServerContainerDefinition": { "ContainerName": "game-server", . . . }, . . . } }Note the
GameServerContainerDefinition.ContainerNamevalue (for example,game-server). -
Identify the game server container runtime ID. Using the game server container name from the previous step, find the matching entry in the
ContainerIdentifiersfrom theget-compute-accessresponse in step 2. Note theContainerRuntimeIdvalue. -
Connect to the container. Use the
ContainerRuntimeIdas the container ID and run the following command:sudo docker exec -it02accb92cd9bef3373300e7151d5c2b3dcca3b06eff1bb4e345085fc008d4678sh
Viewing container port mappings
Port mappings show how container ports map to connection ports on your fleet instances. Each container port that accepts inbound traffic is assigned a connection port on the instance. You can check port mappings to discover which connection ports map to your container ports or to troubleshoot connection issues. You can view port mappings in the Amazon GameLift Servers console, or use the AWS CLI or AWS SDK.
Viewing port mappings in the console
To view port mappings in the console
-
In the Amazon GameLift Servers console, choose Managed containers from the navigation pane, and then Fleets.
-
Choose a fleet to open the fleet details page.
-
View port mappings on one of the following pages:
-
Instance details page â Shows port mappings for the per-instance container group on the selected instance.
-
Compute details page â Shows port mappings for the game server container group on the selected compute.
-
Both pages include a search field to filter port mappings by container name.
Viewing port mappings with the AWS CLI
Use the describe-container-group-port-mappings command to retrieve port
mappings for a container group on a fleet instance. Specify the container group type and
either a --compute-name (for game server groups) or an --instance-id
(for per-instance groups). Optionally, include the --container-name parameter
to filter results to a specific container.
Example: Game server container group
The following command retrieves port mappings for the game server container group on a specific compute.
aws gamelift describe-container-group-port-mappings \ --fleet-idfleet-2222bbbb-33cc-44dd-55ee-6666ffff77aa\ --container-group-type GAME_SERVER \ --compute-name62c5ff7f7a9a445d84877074c80aeafc
If successful, Amazon GameLift Servers returns a response like the following:
{ "FleetId": "fleet-2222bbbb-33cc-44dd-55ee-6666ffff77aa", "Location": "us-west-2", "ContainerGroupDefinitionArn": "arn:aws:gamelift:us-west-2:123456789012:containergroupdefinition/MyGameServerGroup", "ContainerGroupType": "GAME_SERVER", "ComputeName": "62c5ff7f7a9a445d84877074c80aeafc", "InstanceId": "i-1234567890abcdef0", "ContainerGroupPortMappings": [ { "ContainerName": "MyGameServer", "ContainerRuntimeId": "a1b2c3d4e5f6", "ContainerPortMappings": [ { "ContainerPort": 7777, "ConnectionPort": 1025, "Protocol": "UDP" }, { "ContainerPort": 8080, "ConnectionPort": 1026, "Protocol": "TCP" } ] } ] }
Example: Per-instance container group
The following command retrieves port mappings for the per-instance container group on a specific instance.
aws gamelift describe-container-group-port-mappings \ --fleet-idfleet-2222bbbb-33cc-44dd-55ee-6666ffff77aa\ --container-group-type PER_INSTANCE \ --instance-idi-1234567890abcdef0
If successful, Amazon GameLift Servers returns a response like the following:
{ "FleetId": "fleet-2222bbbb-33cc-44dd-55ee-6666ffff77aa", "Location": "us-west-2", "ContainerGroupDefinitionArn": "arn:aws:gamelift:us-west-2:123456789012:containergroupdefinition/MyPerInstanceGroup", "ContainerGroupType": "PER_INSTANCE", "InstanceId": "i-1234567890abcdef0", "ContainerGroupPortMappings": [ { "ContainerName": "MySupportContainer", "ContainerRuntimeId": "f6e5d4c3b2a1", "ContainerPortMappings": [ { "ContainerPort": 8443, "ConnectionPort": 2025, "Protocol": "TCP" } ] } ] }