今天要在我的本子上搭建一個(gè)mediawiki環(huán)境,之前的經(jīng)驗(yàn),用fig去配置是最簡(jiǎn)單的了。可是下載fig失敗,去官網(wǎng)一看才知道,fig已經(jīng)被compose工具取代了。原文是這樣說的:
Fig has been replaced by Docker Compose, and is now deprecated. The new documentation is on the Docker website.
既然如此,就去官網(wǎng)看看compose到底為何物。
compose是用來在docker中定義和運(yùn)行復(fù)雜應(yīng)用的小工具,比如在一個(gè)文件中定義多個(gè)容器,只用一行命令就可以讓一切就緒并運(yùn)行。它的功能與我們所熟知的fig相似,換句話說,compose是fig的替代產(chǎn)品,fig就這樣退出docker的歷史舞臺(tái)了。
然而在github上的compose有這樣的說法:
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工具的環(huán)境用fig去搭建mediawiki都不可用了,報(bào)錯(cuò)如下:
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
其他平臺(tái)可以像python包一樣安裝:
$ sudo pip install -U docker-compose
2.命令簡(jiǎn)介
$ 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,內(nèi)容如下:
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.創(chuàng)建并啟動(dòng)mediawiki
$ docker-compose up -d
更多建議: