Connect 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.
Connect to a container
Before you start:
Connect to the fleet instance. For instructions, see Connect to fleet instances.
Run the following command to list running containers on the instance:
sudo docker ps
The 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 ID column. This gives you full read and write access to the
container filesystem.
sudo docker exec -itcontainer-short-idsh
Connect 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.
-
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. The system authenticates your session through AWS Key Management Service (AWS KMS) and opens a terminal in your browser.
-
Once you have connected to the instance, paste the docker command from step 4 and execute it on the instance to access the container.
Connect to container hosting a game session
To connect to the game server container hosting a specific game session, follow these steps.
-
Get the compute name. Call describe-game-sessions to get the
ComputeNamefor the game session.Request
aws gamelift describe-game-sessions \ --fleet-id fleet-2222bbbb-33cc-44dd-55ee-6666ffff77aa \ --game-session-id arn: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-id fleet-2222bbbb-33cc-44dd-55ee-6666ffff77aa \ --compute-name 62c5ff7f7a9a445d84877074c80aeafcResponse
{ "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 Connect 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 \ --name arn: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 -it 02accb92cd9bef3373300e7151d5c2b3dcca3b06eff1bb4e345085fc008d4678 sh