- Introduction Scale Out with Docker Swarm
- Docker-machine
- Private registry
- Initial source
- Update source
- Update s3
- Build image
- Build image and change tag with localhost:5000
- Build image with localhost:5000 for private repository
- Push Image to Pirvate registry
- Run stack
- Stop stack
- Changing Scale
- Update latest image
- Trouble shooting
- Docker Swarm with Jenkins
CW-OVP can have many background job for video packaging and encoding with ffmpeg.
You must do scale out in production environment due to you require HA and saving time.
If you want get scale in
, you can get it but you know scale in
cost is expensive more than scale out
.
I provide scale out of solution with docker swarm.
I recommend 16 core for each server of worker node
but mininum spec is 4 or 8 or more core
.
https://www.changwoo.org/[email protected]/2020-11-04/docker-machine-create-AWS-ec2-eefe152281
If you want run on local PC or docker-machine driver with aws or digital ocean or another cloud service that support docker-machine, Do use docker-machine. But if you don't wanna docker-machine, bypass this section go to next section of Private registry
- Reference
brew install virtualbox
brew install docker-machine
docker-machine create -d virtualbox master
docker-machine create -d virtualbox worker1
docker-machine create -d virtualbox worker2
docker-machine ls
aws
docker-machine create -d amazonec2 \
--amazonec2-region us-west-1 \
--amazonec2-instance-type "m5.large" \ #--amazonec2-instance-type "t2.micro" \
--amazonec2-ssh-keypath ~/.ssh/id_rsa \ #--amazonec2-ssh-keypath ~/.ssh/ssh_key \
aws-test
if you don't have virtualbox. you got blow of message.
VBoxManage not found. Make sure VirtualBox is installed and VBoxManage is in the path.
docker-machine ssh master
### or eval "$(docker-machine env master)"
docker@master:~$ docker swarm init --advertise-addr 192.168.99.100
Swarm initialized: current node (4l396ni602807sb2hk1ujlvm5) is now a manager.
To add a worker to this swarm, run the following command:
docker swarm join --token SWMTKN-1-5jcphjyj4ykejxphj2o15yh7bz4syyxo5qg8bt25ldkhd4poez-1l2skxj2931mtjolwd43139jy 192.168.99.100:2377
To add a manager to this swarm, run 'docker swarm join-token manager' and follow the instructions.
if you want get token for worker again
docker swarm join-token worker
docker-machine ssh worker1
( '>')
/) TC (\ Core is distributed with ABSOLUTELY NO WARRANTY.
(/-_--_-\) www.tinycorelinux.net
docker@worker1:~$ docker swarm join --token SWMTKN-1-5jcphjyj4ykejxphj2o15yh7bz4syyxo5qg8bt25ldkhd4poez-1l2skxj2931mtjolwd43139jy 192.168.99.100:2377
This node joined a swarm as a worker.
docker-machine ssh worker2
( '>')
/) TC (\ Core is distributed with ABSOLUTELY NO WARRANTY.
(/-_--_-\) www.tinycorelinux.net
docker@worker2:~$ docker swarm join --token SWMTKN-1-5jcphjyj4ykejxphj2o15yh7bz4syyxo5qg8bt25ldkhd4poez-1l2skxj2931mtjolwd43139jy 192.168.99.100:2377
This node joined a swarm as a worker.
docker-machine ssh master
docker service create --name registry --insecure-registry=[myip]:5000 --constraint 'node.role == manager' --publish published=5000,target=5000 registry:2
curl http://localhost:5000/v2/
sudo vim /etc/docker/daemon.json
{"insecure-registries":["your ip:5000"] }
sudo service docker restart
https://github.com/docker/distribution/issues/1874
git clone https://github.com/x1wins/CW-OVP.git
cd ./CW-OVP
git fetch
git checkout master # or feature/docker-stack
if you change source, use
git pull or fetch
cd CW-OVP/
git pull
git checkout master
git reset --hard origin/master # or origin/feature/docker-machine
vi .env.dev.s3
- build image and change tag with localhost:5000
docker build -t cw-ovp:latest . docker tag cw-ovp:latest localhost:5000/cw-ovp docker tag localhost:5000/cw-ovp:latest 127.0.0.1:5000/cw-ovp
- build image with localhost:5000 for private repository
docker build -t 127.0.0.1:5000/cw-ovp .
docker push 127.0.0.1:5000/cw-ovp
docker stack deploy --compose-file docker-stack.yml CW-OVP
docker image prune -a -f
docker exec -it 1f7193e6042e bundle exec rails webpacker:install
docker exec -it 1f7193e6042e bundle exec rake db:migrate
- visual display url
- CW-OVP url
docker stack rm CW-OVP
docker@master:~/CW-OVP$ docker service scale CW-OVP_web=1
CW-OVP_web scaled to 1
overall progress: 1 out of 1 tasks
1/1: running [==================================================>]
verify: Service converged
docker@master:~/CW-OVP$ docker service ls
ID NAME MODE REPLICAS IMAGE PORTS
jc1sqff4pyni CW-OVP_db replicated 1/1 postgres:10.10 *:5432->5432/tcp
i5mpujb9hqh5 CW-OVP_redis replicated 1/1 redis:latest *:6379->6379/tcp
7olizwz0kn9g CW-OVP_sidekiq replicated 2/2 127.0.0.1:5000/cw-ovp:latest
tyu6zey671ky CW-OVP_visualizer replicated 1/1 dockersamples/visualizer:stable *:8080->8080/tcp
mgwbtswxctjk CW-OVP_web replicated 1/1 127.0.0.1:5000/cw-ovp:latest *:3000->3000/tcp
kchi30notd2m registry replicated 1/1 registry:2 *:5000->5000/tcp
docker service update --image 127.0.0.1:5000/cw-ovp CW-OVP_web
# docker service update --image <username>/<repo> <servicename>
docker service ps --no-trunc {serviceName}
docker service ps --no-trunc t9zabkgynr8c
docker service ps --no-trunc kged4le7e3jn
mkdir /home/docker/CW-OVP/tmp/redis
mkdir /home/docker/CW-OVP/tmp/db
docker service create \
--name=viz \
--publish=8080:8080/tcp \
--constraint=node.role==manager \
--mount=type=bind,src=/var/run/docker.sock,dst=/var/run/docker.sock \
dockersamples/visualizer
- https://www.portainer.io/installation/
- https://github.com/portainer/portainer
- you can connect http://192.168.99.100:9000 with web browser
curl -L https://downloads.portainer.io/portainer-agent-stack.yml -o portainer-agent-stack.yml
docker stack deploy --compose-file=portainer-agent-stack.yml portainer
$ git clone https://github.com/stefanprodan/swarmprom.git
$ cd swarmprom
ADMIN_USER=admin \
ADMIN_PASSWORD=admin \
SLACK_URL=https://hooks.slack.com/services/TOKEN \
SLACK_CHANNEL=devops-alerts \
SLACK_USER=alertmanager \
docker stack deploy -c docker-compose.yml mon