This repository was archived by the owner on Oct 9, 2018. It is now read-only.
Open
Conversation
added 3 commits
May 19, 2017 13:59
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
R= @chentaoyu @ruoru
使用 Docker 部署服务端应用
关于如何开始使用,请阅读 Getting Started with Docker 文档。
为何使用 Docker 部署?
Docker 的劣势?
在 CentOS 上安装并启动 Docker CE
参考 Docker CE for CentOS。安装命令如下
在 macOS Sierra 上安装并启动 Docker CE
参考 Docker CE for Mac。下载并安装 Docker.dmg,然后从 LaunchPad 启动 Docker.app 即可。
Docker 服务器运维常用命令
查看帮助文档
查看当前 Docker 进程
启动 Docker 进程
常用 options
-d将 Docker 作为服务 (daemon) 启动
--name <name>赋予容器一个唯一的名字。默认会添加一个随机生成的名字
-p <vm_port>[:<host_port>]将容器的
vm_port绑定到 host 的host_port上-e <env_name>=<env_value>设置容器的环境变量
--restart {no|always|failure}容器是否自动重启
-v <vm_volume>[:<host_volume>]--link <peer_container>完整的选项请参见 docker run 官方文档 或
docker run --help结束 Docker 进程
清除已退出 container
查看 log
目前使用 Docker 部署的应用
gateway
gateway 是目前产品的资源服务器。可以使用 spawn.sh 来启动 gateway:
spawn gateway
resque-workers
resque-workers是和 gateway 配套的一个 workers 进程处理器。目前 resque-workers 主要提供短信发送功能。resque-workers 也可以使用 spawn.sh 来启动
spawn resque-workers
mongodb1
mongodb数据库可以使用 docker run 命令来启动
docker run -d
--restart always
--name mongo
-p 27017
mongo:latest
redis
redis可以使用 docker run命令启动
docker run -d
--restart always
--name redis
-p 6379
redis:alpine
registry
registry是存储 Docker images 的内部服务。目前 registry 部署在 docker.theweflex.com 域名下,在测试服务器上。
docker run -d
--restart always
--name registry
-p 5000
registry
Footnotes
生产环境下,为了优化性能,mongo 和 redis 部署在独立的服务器上 ↩