Answer the question
In order to leave comments, you need to log in
What is the correct method to deploy an application in docker containers on a vps?
I implemented a demo application on nodejs, then when the moment came to roll it out to the server, I decided to use docker and
created a configuration file
version: "3"
services:
nginx:
image: nginx:1.13-alpine
restart: always
ports:
- "80:80"
depends_on:
- node
links:
- "node"
volumes:
- "./nginx:/etc/nginx/conf.d"
- "./static:/var/www/static"
node:
build:
context: ./server
dockerfile: Dockerfile
volumes:
- ./server:/var/www/server
- ./static:/var/www/static
- ./logs:/var/www/logs
depends_on:
- db
- redis
links:
- "db"
- "redis"
command: pm2-docker start /var/www/server/run.json --no-auto-exit
environment:
SQL_HOST: db
SQL_USER: postgres
SQL_PASSWORD: postgres
SQL_DB: postgres
REDIS_HOST: redis
db:
image: postgres:10-alpine
volumes:
- "./server:/var/www/server"
- "./pg:/var/www/pgdata"
restart: always
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: postgres
PGDATA: /var/www/pgdata
redis:
image: redis:4-alpine
volumes:
- ./redis/conf/redis.conf:/usr/local/etc/redis/redis.conf
Answer the question
In order to leave comments, you need to log in
Of course, it's redundant, given that swarm and kubrnetes support up to five thousand servers and who the hell knows how many containers, this is not your case.
orchestrators are superfluous in your case, most of them will require at least one more master server. Docker Compose is more than enough for testing and deployment within 1 server.
Docker Swarm gives low overhead and can be run on a single machine very easily. It makes sense if you plan to increase the number of cars.
Another thing is that the author does not need Swarm here when it comes to deployment. I see 3 options:
1. We connect via SSH, we do it on the server git pull
, then docker-compose up -d
, everything is done by hand.
2. We use docker-machine. It works with both docker stack and old compose. There is a lot of information on the Internet, you can set up auto-deploy.
3. Use something like ansible, similar to the second option, but a more flexible solution and allows you to configure the server if you need a specific configuration, for example. Similarly, you can set up auto-deploy.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question