🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
今天要在我的本子上搭建一个mediawiki环境,之前的经验,用fig去配置是最简单的了。可是下载fig失败,去官网一看才知道,fig已经被compose工具取代了。原文是这样说的: ~~~ Fig has been replaced by Docker Compose, and is now deprecated. The new documentation is on the Docker website. ~~~ 既然如此,就去官网看看compose到底为何物。  [compose](http://docs.docker.com/compose/)是用来在docker中定义和运行复杂应用的小工具,比如在一个文件中定义多个容器,只用一行命令就可以让一切就绪并运行。它的功能与我们所熟知的fig相似,换句话说,compose是fig的替代产品,fig就这样退出docker的历史舞台了。 然而在[github上的compose](https://github.com/docker/compose/releases/)有这样的说法: ~~~ Fig has been renamed to Docker Compose, or just Compose for short. This has several implications for you: The command you type is now docker-compose, not fig. You should rename your fig.yml to docker-compose.yml. ~~~ 看来fig是被重命名成compose了,配置文件变成了docker-compose.yml,其他都几乎一样。不但fig不能下载了,原来有fig工具的环境用fig去搭建mediawiki都不可用了,报错如下: ~~~ fig up -d Creating hgserver_mediawiki_1... Pulling image amclain/hgweb... Traceback (most recent call last): File "<string>", line 3, in <module> File "/code/build/fig/out00-PYZ.pyz/fig.cli.main", line 31, in main File "/code/build/fig/out00-PYZ.pyz/fig.cli.docopt_command", line 21, in sys_dispatch File "/code/build/fig/out00-PYZ.pyz/fig.cli.command", line 28, in dispatch File "/code/build/fig/out00-PYZ.pyz/fig.cli.docopt_command", line 24, in dispatch ... fig.progress_stream.StreamOutputError: Get https://index.docker.io/v1/repositories/amclain/hgweb/images: dial tcp: lookup index.docker.io on 10.202.72.118:53: read udp 10.202.72.118:53: i/o timeout ~~~ 如此看来,使用compose是必须的了。  下面说说compose的用法。  1.安装compose  OS X和64位的Linux用如下命令安装。 ~~~ # curl -L https://github.com/docker/compose/releases/download/1.1.0/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose #chmod +x /usr/local/bin/docker-compose ~~~ 其他平台可以像python包一样安装: ~~~ $ sudo pip install -U docker-compose ~~~ 2.命令简介 ~~~ $ docker-compose Fast, isolated development environments using Docker. Usage: docker-compose [options] [COMMAND] [ARGS...] docker-compose -h|--help Options: --verbose Show more output --version Print version and exit -f, --file FILE Specify an alternate compose file (default: docker-compose.yml) -p, --project-name NAME Specify an alternate project name (default: directory name) Commands: build Build or rebuild services help Get help on a command kill Kill containers logs View output from containers port Print the public port for a port binding ps List containers pull Pulls service images rm Remove stopped containers run Run a one-off command scale Set number of containers for a service start Start services stop Stop services restart Restart services up Create and start containers ~~~ 3.compose编写mediawiki的docker-compose.yml  首先编写compose的配置文件,语法与fig类似,文件名为docker-compose.yml,内容如下: ~~~ wiki2: image: 'nickstenning/mediawiki' ports: - "8880:80" links: - db:database volumes: - /data/wiki2:/data db: image: "mysql" expose: - "3306" environment: - MYSQL_ROOT_PASSWORD=defaultpass ~~~ 4.创建并启动mediawiki ~~~ $ docker-compose up -d ~~~