Setup Nginx, Docker, and Portainer on VPS

image from pixels

Most important if setup newest VPS is setup the docker and docker-compose, In this case, I will share how to setup Docker, Nginx, docker-compose

Install Docker

To Install Docker we need to install some dependencies, in this case, my VPS is Debian based so use this command to get the dependencies

apt install curl gnupg2 ca-certificates lsb-release

Get the key

curl -fsSL https://download.docker.com/linux/debian/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg

Now add in the repo

echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/debian \
$(lsb_release -cs) stable" | tee /etc/apt/sources.list.d/docker.list > /dev/null

Then install the docker

apt update && apt-get install docker-ce docker-ce-cli containerd.io
docker-engine

Install Docker Compose

Now Install docker-compose for multi-container with YAML configuration, install with this command

apt -y install apt-transport-https ca-certificates curl gnupg2 software-properties-common

Getting Docker Compose

curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose

Change owner for docker-compose

chmod +x /usr/local/bin/docker-compose

Linking the compose to the system

ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose

Checking the version

docker-compose --version
checking the version

Install Portainer UI

To simplify docker management we need a tool manager to manage containers and docker images

Creating Directory to store portainer data

mkdir ~/portainer

Pull Portainer latest version

docker pull portainer/portainer

Tag on Directory

docker pull portainer/portainer

running the container

export CONT_NAME="portainer" # Create container docker run -d -p 9000:9000 \ --restart always \ -v /var/run/docker.sock:/var/run/docker.sock \ -v ~/portainer:/data \ --name ${CONT_NAME} \ portainer

open the portainer on web browser

portainer on Server

Installing Web Service Nginx

Installing web service for non-docker apps

apt install curl gnupg2 ca-certificates lsb-release nginx

Conclusion

that’s how to setup docker for a new VPS so it’s ready to be used for production or staging servers with a manager that makes the process of deploying and testing applications easier

Interesting with Blockchain and Opensource Project my journal: https://www.perykun.xyz/

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

The Perfect Script Tool for Esri’s ArcGIS Pro

CodeSubmit for Mobile App Developer Assessment

Interfacing 7 segment display to 89C51 micro controller.

AWS — Using Elastic Beanstalk to Launch Your Application

A simple guide to EV navigation and routing

Tesla Model X recharging in Saint-Malo, France.

Use An API To Get Historical Flights

How to Build and Publish your own Python Command Line Tool

Bokeh 0.12.15 Released

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Feri Lukmansyah

Feri Lukmansyah

Interesting with Blockchain and Opensource Project my journal: https://www.perykun.xyz/

More from Medium

Deploy Containerized Flask app to Heroku

Docker and Containerization

How to Manage and Use Apache virtual hosts in Ubuntu

Deploying a Docker Container on EC2