I am planning to move docker-compose to docker-swarm for multi nodes.
I have used docker-compose
like this below
version: '3'
services:
python:
container_name: python
build: ./python
command: uwsgi --socket :8001 --module myapp.wsgi --py-autoreload 1 --logto /tmp/mylog.log
volumes:
- ./src:/code
- ./src/static:/static
ports:
- "8082:8082"
expose:
- "8001"
nginx:
image: nginx:1.13
container_name: nginx
ports:
- "8000:8000"
volumes:
- ./nginx/conf:/etc/nginx/conf.d
- ./nginx/uwsgi_params:/etc/nginx/uwsgi_params
- ./static:/static
depends_on:
- python
it works well for django host.
then now I am trying to use docker-swarm
.
docker-compose
and docker-swarm
looks alike, but there is one question.
I mounted the local drives like this
- ./src:/code
- ./src/static:/static
or here
- ./nginx/conf:/etc/nginx/conf.d
- ./nginx/uwsgi_params:/etc/nginx/uwsgi_params
- ./static:/static
However in docker-swarm
, volumes
like this doesn't work and service never starts.
(I see... it is understandable, because there might be many nodes..)
I think I should do some changes.
I googled around and found out there is some settings like this .
services:
python:
volumes:
- src:/code
volumes:
src:
driver: local
However I don't understand how to use this ...
Where should I put my source code or some config file ??
What is the best practice for docker-swarm common used file ??