Deploy your Dockerized Backend app with Linode and Docker Hub

BAILLAHI Lemine
6 min readOct 16, 2024

--

Using Cloud solutions became crucial for more production availability and built-in environment security, reliability and support. But sometimes it gets pricy especially when you’re trying to deploy a small service or a POC (Proof Of Concept) and here comes the choice of Linode as a relatively cheap cloud provider with an easy user-experience.

Why not AWS or GPC ?

Cloud providers such as AWS and GCP are great, especially -in my opinion- AWS and it’s just amazing how they’ve a huge amount of various cloud services that makes them -in my opinion- the best option of companies who’re willing to go cloud and for Startups, but they’re maybe not the best fit when it comes to deploying a small single service, a testing service or a POC, or when pricing is your first criteria to choose besides these services (AWS & GCP) have an advanced dashboards that might not be suitable to easily understand by everyone.

What about AWS & GCP Free tier ?

  • AWS free tier: AWS again gives a big amount of services in the free tier that’s available for the first year, but for the instances it gives only a micro instance that limits your app deployment to 1vcpu and 1Go of RAM. This micro instance will cost you 0.0116$ per hour after the free tier which means around 8$ per month.
  • GCP free tier: GCP too offers an interesting pack in the free tier, you can get 200$ for the free tier that will expire before you use it 😅​, and they offer an instance e2-micro for around 7$ per month for 2vCPUs and 1Gb RAM.

So, basically the choice of Linode over AWS and GCP was made only for so specific use-cases:

  • small and simple service
  • pricing
  • user-experience

Before deploying on Linode, Our instance or our Linode -as they call- it will cost 5$ per month

Build and publish the backend app docker image

In this example we’ll deploy a sample Spring-boot Netflix DGS graphql api that has a Dockerfile looks like:

And our API has one Query that shows “Hello World!”

Let’s now build our docker image and push it to a Docker registry. In this article we’ll deploy our image to Docker Hub.

In the image as below, i’ve created a sample spring-boot api repository to push our Docker image

docker-hub-image-repository

You can find the repo here

So, time to build and push the docker image

docker build -t sample-spring-boot-api .

docker image tag <your_docker_hub_repo_name>/spring-boot-sample-api

docker login

docker push

docker-push-complete-success

If everything goes well, then you should find the image pushed in your Docker repo as in the picture as below:

Docker image respository

You can pull this article’s docker image from here

Deploy the Dockerized app on Linode:

Now, it’s time to deploy our dockerized app on Linode, so, let’s go to Linode and create our service. Once you’re logged-in, click on Linodes then “Create Linode” as shown in the picture as below

Then choose “Marketplace” from the tabs. this will show a list of Marketplace ready to use managed services such as WordPress, PostgreSQL and a lot more

Now search for “Docker” and choose Docker as in the picture as below

Then scroll down to fill your configuration information

And pick your plan with “us-east” as zone, “Shared CPU” as Linode and check the first option of 1 GB RAM and 1 CPUs

N.B: here we chose “us-east” and “Shared CPU”, these two will increase of decrease your pricing.

Then scroll down to give your password to connect to your instance

You can give it a label or leave everything to the default values.

Next you can optionally set-up a firewall, we’ll leave everything to the default.

Last but not least, optionally you can create a static private IP, backup your instance (for additional 2$) or leave them all as default.

Once all set-up, click on “Create Linode”, this will setup your instance and goes from Provisioning to Running as in the images as below

Provisioning the instance
Instance is Running

Now, the instance is well set-up, let’s connect to it with ssh

ssh root@<your_instance_ip>

then it will request your password, type the password that you chose in the instance creation. Once you’re in, check if docker is well install (since we’ve chosen a docker based instance)

docker ps

This should print the list of docker running containers.

Now we’re ready to pull our docker image from Docker Hub

docker pull sherlocklemine/spring-boot-sample-api

docker images

Then we run our backend docker container

docker run -p 80:8080 — name sample-springboot-api-container -d sherlocklemine/spring-boot-sample-api:latest

This will run your backend in a detached mode, you can run it as well in an attached mode simply by removing the “-d” from the command to track the full log (you can do this with docker logs <container_id>)

docker container logs

Once the app’s startup is complete, open the browser at http://<instance_ip>:<exposed_port>/graphiql, you should see our stunning graphql playground as in the image as below

deployed docker container

And like this we just deployed our sample spring-boot graphql api on Linode.

Recommendation:

If your situation matches the context of this article and you want to deploy a simple service that doesn’t cost a lot with an easy cloud management dashboard experience, then go for Linode.

But if you’re looking for full backend cloud provider that you’ll rely on for all your backend services, then i’d highly recommend AWS for two main reasons:

  • Huge set of services: Basically AWS is a real big whale, you can find everything from VM, K8s, AWS Fargate (alternative of K8S) to AI ..
  • Customer support: this is decisive point, i’ve tried before GCP and unfortunately they’ve a poor customer support.
  • Startups support: they give 10K$ free services consumption for Startups

--

--

BAILLAHI Lemine
BAILLAHI Lemine

No responses yet