Ask HN: Should I learn Docker to deploy my app in VPS?
for more context, my primary language is javascript, but lately i started learning Golang,in the past i only use normal hosting providers to host my nodejs apps
Every developer should learn the basics of Servers, Linux, VPS hosting etc. It is not that hard especially with the amount of information that's online. You mentioned Golang. For those languages, it is even easier because you literally host a single binary on the VPS. So go ahead, learn it. The naysayers will scare you into thinking that you need someone else to do it for you but you usually don't. Not unless you are running an app with mission critical requirements and at scale.It is totally ok to host your own app on a VPS that gets a few hundred requests in a day or even more.
My suggestions:
1. Start with a specific OS on a linux box. Ubuntu is a standard one that you can just start with.
2. Install your application first without docker. If binary (e.g. Golang), you can literally copy the binary (make sure you build it for your OS on the server) and then run it either using something ike supervisor/systemd
3. Then, use a reverse proxy like Caddy in front of it for SSL and actual domain.
4. Get a custom domain from any provider and set the DNS for that domain to point to the IP address of this server.
5. If you want to get real fancy, instead of pointing d0main directly to the IP of the server, get a DNS with cloudflare and point there. Then configure cloudflare to point to the actual server (a.k.a origin server) This way, you get additional benefits like WAF, DDOS protection etc. Even cloudflare free plan offers this with some limits.
Then repeat the process in 2,3 but with docker container.
You can do all of this easily in ChatGPT etc nowadays by asking:
- I want to install a Go App on an Ubuntu VPS using systemd/supervisor and put Caddy as reverse proxy in front. Then I will want to use a custom domain where DNS is hoted with Cloudflare which ultimately points to Caddy.
Should you learn - yes. Do you really need it - probably not now, but eventually yes. I use it always to set up my dev environment so that the team can have a consistent environment to work on.
Installing docker is generally simple. Docker desktop on windows or just follow the steps in the docks for linux.
Reading and using a simple dockerfile is also dead simple.
Understanding compose and port and volume mapping is a bit trickier but not daunting.
Once you have the basics of understanding a dockerfile you can switch to doing container based development in vscode and you will never go back to writing code on your host again.
Vscode is not the only ide that supports this, just the one I use most of the time. There are also docker alternatives like rancher and postman but I still use docker when doing dec work.
Good luck. Bit of beginner advice though. Take time to understand the differences between: build, up, down, stop, start
My suggestions:
1. Start with a specific OS on a linux box. Ubuntu is a standard one that you can just start with.
2. Install your application first without docker. If binary (e.g. Golang), you can literally copy the binary (make sure you build it for your OS on the server) and then run it either using something ike supervisor/systemd
3. Then, use a reverse proxy like Caddy in front of it for SSL and actual domain.
4. Get a custom domain from any provider and set the DNS for that domain to point to the IP address of this server.
5. If you want to get real fancy, instead of pointing d0main directly to the IP of the server, get a DNS with cloudflare and point there. Then configure cloudflare to point to the actual server (a.k.a origin server) This way, you get additional benefits like WAF, DDOS protection etc. Even cloudflare free plan offers this with some limits.
Then repeat the process in 2,3 but with docker container.
You can do all of this easily in ChatGPT etc nowadays by asking:
- I want to install a Go App on an Ubuntu VPS using systemd/supervisor and put Caddy as reverse proxy in front. Then I will want to use a custom domain where DNS is hoted with Cloudflare which ultimately points to Caddy.
It is not that hard. Not to learn at least.
testing your app as-a-container locally before pushing is a worthwhile check to ensure you don’t have config/startup issues
learning docker is a separate skill, yet is versatile, you can wrap anything in an OCI image
Installing docker is generally simple. Docker desktop on windows or just follow the steps in the docks for linux.
Reading and using a simple dockerfile is also dead simple.
Understanding compose and port and volume mapping is a bit trickier but not daunting.
Once you have the basics of understanding a dockerfile you can switch to doing container based development in vscode and you will never go back to writing code on your host again.
Vscode is not the only ide that supports this, just the one I use most of the time. There are also docker alternatives like rancher and postman but I still use docker when doing dec work.
Good luck. Bit of beginner advice though. Take time to understand the differences between: build, up, down, stop, start