(Serverless or Docker) Which host to choose?
Tags: serverless, docker, server, shopify
Published: 2022-03-10 23:53:12

---
title: (Serverless or Docker) Which host to choose?
published: true
description: This post share a conclusion I had finishing my Shopify Hydrogen course I taught how to host it in a Serverless vs Container-based hosting.
tags: serverless, docker, server, shopify
cover_image: https://i0.wp.com/rafaelcg.com/wp-content/uploads/2022/02/shopify-hydrogen-app-sample-docker.png
canonical_url: https://rafaelcg.com/blog/vm-docker-serverless/
---

![Docker vs Serverless](https://i0.wp.com/rafaelcg.com/wp-content/uploads/2022/02/shopify-hydrogen-app-sample-docker.png?fit=1235%2C905&ssl=1)

I see many developers struggling to decide between using serverless or not within an MVP. The first thing to analyze is if your new project doesn't have hosting limits. As I ever say, it's essential to understand the trade-offs you might have. Be aware of the exchanges, and you will know what answers you need to decide between possible solutions.

![Serverless, Containers, Virtual Machines and Servers with each respective time to deploy.](https://i0.wp.com/rafaelcg.com/wp-content/uploads/2022/02/Serveless-vs-Docker-vs-Virtual-Machine.png?resize=665%2C167&ssl=1)

Serverless
----------

Having the chance to use serverless, I recommend trying it first. It will reduce the complexity to launch your projects; the trade-off here is flexibility. It is harder to replicate the backend in a local environment to test serverless web applications. It's essential to consider the point that your application might be prepared for the environment. Using containers, you would create an environment with your application requirements.

[![Cloudflare Workers Serverless](https://i0.wp.com/rafaelcg.com/wp-content/uploads/2022/02/Cloudlfare-Workers.png?resize=840%2C655&ssl=1)](https://workers.cloudflare.com/)

Containers
----------

Compared with serverless, deploying containers run the same no matter where they are, which means more precise local tests. During the Shopify App development, I missed a clear container to work and deploy to production, that's when I applied [Containers to my Shopify development](https://rafaelcg.com/blog/developer/shopify-apps-on-visual-studio-code/) workflow.

I usually use a Docker container for applications that aren't as simple as a microservice. A container allows you to deploy to production and have the same container running in your local environment.

[![Shopify Hydrogen running on Digital Ocean with Docker](https://i0.wp.com/rafaelcg.com/wp-content/uploads/2022/02/shopify-hydrogen-app-sample-docker.png?resize=840%2C615&ssl=1)](https://github.com/clean-docker/shopify-hydrogen)

Probably you know that there are invisible points with containers such as maintainability, security, load balance and other things that you need to monitor and maintain. In more complex structures it's required, but it's essential to have in mind that you might have even more points to take care of if you use a VM or Server.

There are many good points to start using containers; my favourite is the control and freedom to switch to any server with the same infrastructure. In my [Shopify Hydrogen Course](https://rafaelcg.com/course-shopify-hydrogen-developer-2022/) development, we hosted the same theme on Docker container using [DigitalOcean](https://m.do.co/c/c3a8c6b3f90b) and serverless, if you want to check it out.

Virtual Machine and Servers
---------------------------

I didn't have to go through these two kinds of setups during the course development, but I faced situations that required these kinds of implementations. Before containers were popular, serverless even exist.