In terminal, run the command:
aws ecs execute-command --cluster your-cluster-name \
    --task <taskId> \
    --container your-container-name \
    --interactive \
    --command "/bin/sh" 
Note: 
- your-container-name: is the name of container which defined in 'task definitions'
- taskId: it look like 'af8016b7bcaf471cebde247fc85a6165'
- You can change "/bin/sh" to any command as you want
Requirement:
- aws cli installed
- aws Session Manager Plugin installed. Install here