Docker containers are easily one of my favorite pieces of new technology of the
last decade. They’ve immensely simplified how I work locally, no more virtual
machines, no more trying to keep my local development environment and production servers in parity, and no need for command-line sloths like nvm
.
They’ve also changed how we deploy applications to production, going as far as
eliminating the need to run dedicated servers and simplifying the hell out of
clustering applications.
As far as containers have taken us over the years, containers do need to be
restarted between deployments from time to time. Memory leaks, gremlins in our code, and such, contribute to this need.
I typically use AWS Elastic Container Service (ECS) by way of AWS Fargate for micro services. However, one of my services has been experiencing a ghost in the machine, if you will.
Even so, executing an entire CI/CD pipeline to redeploy an ECS container tends to be over kill. Running the linter, tests, and then finally deploying is time consuming and unnecessary when all you need to do is get things redeployed from an already tested and deployed image.
Thankfully, we don’t have to go through the usual CI/CD pipeline. Instead, we can simply update the service, and tell it to force a new deployment, as nothing
will actually be changing.
Steps to restart an AWS ECS instance in the AWS Console
This can be done via the AWS Console (direct links omitted as they are region
specific and I don’t want to add any unnecessary confusion):
- Log into the AWS Management Console.
- Go to Elastic Container Service.
- Go to Clusters.
- Click on the cluster that your service is in.
- Click on the service you’d like to restart.
- Click Update.
- Check Force new deployment about half way down the page.
- Click Skip to review.
- Click Update service.
- Wait patiently as your service restarts!
Steps to start an AWS ECS instance from the CLI
No much to it, but there are quite a few steps involved to make it happen. If
you’re a fan of the AWS CLI (as I am), you can accomplish everything outlined
above with this command:
aws ecs update-service --cluster :clusterName --service :serviceName --force-new-deployment
ZshYou may still want to navigate out to ECS to monitor the status of the
deployment, that’s up to you.