2018-07-25 22:23:58    2018-07-25 22:23:58   

   docker 容器 容器编排 swarm 阿里云

#### **开通阿里云的容器服务** #### **创建专有网络** ![](https://image.ynotes.cn/18-7-25/43311644.jpg) #### **创建交换机** ![](https://image.ynotes.cn/18-7-25/43311644.jpg) #### **创建swarm集群** ![](https://image.ynotes.cn/18-7-25/85719142.jpg) ![](https://image.ynotes.cn/18-7-25/91643015.jpg) ![](https://image.ynotes.cn/18-7-25/99693706.jpg) ![](https://image.ynotes.cn/18-7-25/5548867.jpg) ![](https://image.ynotes.cn/18-7-25/76142867.jpg) ![](https://image.ynotes.cn/18-7-25/36572329.jpg) #### **创建编排模板** ```yaml version: '2' services: db: image: mysql:5.7 restart: always container_name: blog-db environment: MYSQL_ROOT_PASSWORD: 123456 MYSQL_DATABASE: blog MYSQL_USER: blog MYSQL_PASSWORD: 123456 volumes: - /root/blog/mysql/conf/mysqld.cnf:/etc/mysql/mysql.conf.d/mysqld.cnf - /root/blog/mysql/db_init_sql:/docker-entrypoint-initdb.d - /root/blog/mysql/data:/var/lib/mysql - /root/blog/mysql/log:/var/log networks: default: aliases: - db uwsgi-django: image: 'registry.cn-shenzhen.aliyuncs.com/sys/uwsgi-django:1.9.5' restart: always depends_on: - db container_name: blog-uwsgi-django environment: DB_NAME: blog DB_USER: blog DB_PASS: 123456 DB_PORT: 3306 WEB_URL: www.ynotes.cn volumes: - /root/blog/uwsgi-django/my_project:/usr/src/app/my_project - /root/blog/uwsgi-django/conf:/usr/src/app/uwsgi/conf command: uwsgi /usr/src/app/uwsgi/conf/config.ini networks: default: aliases: - uwsgi-django nginx: image: nginx:stable restart: always depends_on: - uwsgi-django container_name: blog-nginx environment: NGINX_HOST: www.ynotes.cn NGINX_PORT: 80 NGINX_SSL_PORT: 443 UWSGI_PORT: 8888 ports: - 8080:80 volumes: - /root/blog/nginx/conf/nginx.conf:/etc/nginx/nginx.conf - /root/blog/nginx/conf/mysite.template:/etc/nginx/conf.d/mysite.template - /root/blog/nginx/ssl/fullchain.pem:/etc/nginx/ssl/blog.itisme.co/fullchain.pem - /root/blog/nginx/ssl/privkey.pem:/etc/nginx/ssl/blog.itisme.co/privkey.pem - /root/blog/uwsgi-django/my_project/my_project/upload:/data/app/my_project/my_project/upload - /root/blog/uwsgi-django/my_project/my_project/static_all:/data/app/my_project/my_project/static_all - /root/blog/uwsgi-django/my_project/my_project/uwsgi_params:/data/app/my_project/my_project/uwsgi_params - /root/blog/nginx/log/:/var/log/nginx/ command: /bin/bash -c "envsubst < /etc/nginx/conf.d/mysite.template > /etc/nginx/conf.d/blog.itisme.co.conf && nginx -g 'daemon off;'" networks: default: driver: overlay ``` #### **配置安全组规则,增加22端口(方便远程拷贝项目)** ![](https://image.ynotes.cn/18-7-25/52826166.jpg) #### **上传blog项目到容器主机/root目录** ```bash $ tar xvf blog.tar.gz ``` #### **创建应用** ![](https://image.ynotes.cn/18-7-25/35869228.jpg) ![](https://image.ynotes.cn/18-7-25/31022136.jpg) #### **查看启动的服务** ![](https://image.ynotes.cn/18-7-26/43336011.jpg) #### **配置SLB负载均衡证书(把申请的证书和私钥粘贴到下面的服务器证书相对应的文本框中)** ![](https://image.ynotes.cn/18-7-26/34424767.jpg) #### **配置SLB负载端口映射(443->8080)** ![](https://image.ynotes.cn/18-7-26/11656277.jpg) ![](https://image.ynotes.cn/18-7-26/92529607.jpg) ![](https://image.ynotes.cn/18-7-26/27217610.jpg) #### **配置dns解析 `www.ynotes.cn` 到slb** #### **访问`https://www.ynotes.cn`** ![](https://image.ynotes.cn/18-7-26/68765124.jpg)

©著作权归作者所有:来自ynotes.cn笔记作者猫的原创作品,如需转载,请注明出处:https://ynotes.cn/blog/article_detail/129

文章分类: 系统     个人分类: 容器

收藏


0 条评论
按时间正序 按时间倒序