Setup Nginx, Docker, and Portainer on VPS

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

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

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

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

--

--

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