Deploy golang API in Digital Ocean using docker container

How deploy golang API with docker container


Before going forward, make sure golang program work locally and ready to deploy.

  • Prepare your project with Docker configuration (Dockerfile).
  • Also need to push the project to Github and update the module structure.
  • Golang modules should structured like github.com /username/ repo-name/module and re-initialize with
go mod init /username/repo-name

Droplet

Create Docker Droplet in the DigitalOcean Cloud. In the console (cloud) clone the Github repository and build docker image.

Let’s run the container, which is similar to what do you have done in development machine.

Please see golang docker guide for more instructions

Go to your browser and try accessing API , eg: 137.184.188.21:8080 and it should work.

Don’t have a DO Account yet ?, Use this $100 and get started ?

DigitalOcean Referral Badge

Create a docker droplet in DigitalOcean

How to setup docker container on digital ocean cloud


Droplets allow us to create virtual machines for computing, containerizing deployment, hosting WordPress etc.

To use docker in our droplet, have to use the Marketplace tab and choose wisely.

Please choose Docker on Ubuntu for containerized deployment.

The cost for DigitalOcean Droplets starts with $5 monthly.

Droplet control panel shows your droplets, you can manage the VM here.

Note that turn off droplet will not stop the billing, destroy the droplet instead.

Don’t have a DO Account yet ?, Use this $100 and get started ?

DigitalOcean Referral Badge

Accessing DigitalOcean droplets in Windows/Linux remotely

How to access DigitalOcean cloud droplets remotely


You can access the Digital Ocean droplet terminal from access panel or can use the ssh to access it remotely.

In Windows I strongly recommend to use Linux Subsystem. I use openSuse and it is cool.

In your terminal fire the command

ssh username@ip 

Here username can be root and IP is the IP of your droplet. Go to the control panel and copy the IP.

Don’t have a DO Account yet ?, Use this $100 and get started ?

DigitalOcean Referral Badge

What is a Droplets in DigitalOcean

How to Virtual machines on digital ocean


Droplets allow us to create virtual machines for computing, containerizing deployment, hosting WordPress etc.

The cost for DigitalOcean Droplets starts with $5 monthly.

Digital Ocean Cloud : Droplets

Droplet control panel shows your droplets, you can manage the VM here.

Note that turn off droplet will not stop the billing, destroy the droplet instead.

Don’t have a DO Account yet ?, Use this $100 and get started ?

DigitalOcean Referral Badge