Better ways to deploy containers to VMs
Posted by maximeridius@reddit | ExperiencedDevs | View on Reddit | 23 comments
So I have a relatively simple setup. Just a group of VMs each with Docker installed and managed with terraform. No Kubernetes or anything like that. Currently to deploy new contains I have a Github action which builds the new image, and then will SSH into the VM, stop and remove the current container, pull down the new container and run it. This is fine and works but also feels a bit manual and error prone. I am curious whether others are taking a similar approach or if there are any other better approaches or tools which you which recommend.
ExperiencedDevs-ModTeam@reddit
Rule 7: No Google-able questions
I.e. no "what are the best language(s), framework(s), tool(s), book(s), resource(s)". Most of these are trivially searchable.
If you must post something like this, please frame it in a larger discussion - what are you trying to accomplish, what have you already considered - don't just crowd-source out something you want to know.
GandolfMagicFruits@reddit
As others have said, Amazon ECR for your container storage and ECS to deploy them to services.
0x11110110@reddit
this is what kubernetes was designed for.
originalchronoguy@reddit
Some people don't want that extra overhead. For example, on my personal projects, I run 2 EC2 AMI instance on Amazon. I just want to push a quick container to it. Sure, I can install minikube but that is 1 hour of setup vs 5 minutes of an apt-get install docker engine. And docker-compose can be written. up in 2 minutes vs 10 minutes for a helm chart.
I am referring to simple setup like OP.
the_pwnererXx@reddit
Middle ground is just ecs
GandolfMagicFruits@reddit
☝️
kbn_@reddit
This. ECS is dead simple. It also hits a hard scaling wall eventually because of how it handles auto scaling (both up and down), but OP is about three orders of magnitude shy of that threshold.
i_like_tasty_pizza@reddit
Just use k3s, Kubernetes without the etcd brain damage.
Constant-Listen834@reddit
Docker-compose is so bad lol
BoBoBearDev@reddit
I am old school, just Jenkins doing it and post Mattermost post if it failed. I can see the progress and logs easily on the Jenkins page. I don't know enough to do k8s in among multiple VMs.
PragmaticBoredom@reddit
A good first step would be to use Terraform to deploy the containers.
You shouldn't have your GitHub actions doing SSH deploys. Use your existing Terraform infrastructure to point to the new containers.
the_pwnererXx@reddit
This is really slow and burdensome, bad advice
Dymatizeee@reddit
Not OP but I use ecr + ecs; compiled my backend via docker into a docker image I upload to ecr
Not sure if I’m doing it right though
look@reddit
I haven’t used it myself yet, but something like Coolify might be of interest:
https://coolify.io/docs/get-started/introduction
They have a managed service (bring your own server) but you can also self-host to save a few dollars/mo.
needadvicebadly@reddit
While I'd recommend professional tools like others, if you want something slightly less manual, maybe something like watchtower with a config to poll your registry once a minute or so?
Internal_Research_72@reddit
Yeah, my dude, you’re trying to re-implement k8s.
angrynoah@reddit
docker pull && docker run
doesn't have to be complicated
ignore the siren song of K8s
SnooPears2424@reddit
are you using AWS? AWS ECS definitely will help you with this.
I am a k8s admin and I would not recommend you jumping into k8s at the moment.
wonkynonce@reddit
Google Cloud Run, Amazon Container Service provide APIs to do this in a slick way. Kubernetes gets a lot of guff for being complicated, but if you pull the thread on "I want a good container management plane that abstracts away the servers", you kind of wind up with Kubernetes.
You could try Hashicorp Nomad, I think they're the last, kind of standing K8S competitor.
nullstacks@reddit
Docker Swarm
OkKindheartedness950@reddit
What about Kamal? I haven’t used it myself but it should help automate the deploy process you’re currently doing manually.
https://kamal-deploy.org/
originalchronoguy@reddit
It is automated? That is what matters. Most orchestrators do all of that under neath the skin.
I do that with Jenkins through a blueprint. It is just a click of a button or through a branch MR. But mechanically, that it is how it is done underneath the blanket.
People have been doing this for close to15 years.
Antique-Stand-4920@reddit
Outside of using a PaaS solution or a Docker orchestrator that's pretty much how it is done for VMs. I've never used Terraform to deploy Docker containers onto a VM, but I've used Ansible years ago.