在线观看不卡亚洲电影_亚洲妓女99综合网_91青青青亚洲娱乐在线观看_日韩无码高清综合久久

鍍金池/ 教程/ Linux/ Docker 實(shí)踐 8:Compose
Docker 實(shí)踐 3:fig 搭建 mediawiki
Docker 實(shí)踐 9:備份方案
Docker 實(shí)踐
Docker 實(shí)踐 2:用 Docker 搭建 hg-server
Docker 實(shí)踐 7:容器與主機(jī)拷貝數(shù)據(jù)
Docker 實(shí)踐 6:Cannot connect to the Docker daemon.
Docker 實(shí)踐 5:搭建 redmine
Docker 實(shí)踐 4:搭建 wordpress
Docker 實(shí)踐 8:Compose

Docker 實(shí)踐 8:Compose

今天要在我的本子上搭建一個(gè) mediawiki 環(huán)境,之前的經(jīng)驗(yàn),用 fig 去配置是最簡(jiǎn)單的了??墒窍螺d fig 失敗,去官網(wǎng)一看才知道,fig 已經(jīng)被 compose 工具取代了。原文是這樣說(shuō)的:

Fig has been replaced by Docker Compose, and is now deprecated. The new documentation is on the Docker website.

既然如此,就去官網(wǎng)看看 compose 到底為何物。

compose 是用來(lái)在 docker 中定義和運(yùn)行復(fù)雜應(yīng)用的小工具,比如在一個(gè)文件中定義多個(gè)容器,只用一行命令就可以讓一切就緒并運(yùn)行。它的功能與我們所熟知的 fig 相似,換句話說(shuō),compose 是 fig 的替代產(chǎn)品,fig 就這樣退出 docker 的歷史舞臺(tái)了。

然而在 github 上的 compose 有這樣的說(shuō)法:

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.

看來(lái) fig 是被重命名成 compose 了,配置文件變成了 docker-compose.yml,其他都幾乎一樣。不但 fig 不能下載了,原來(lái)有 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

如此看來(lái),使用 compose 是必須的了。

下面說(shuō)說(shuō) 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 編寫(xiě) mediawiki 的 docker-compose.yml

首先編寫(xiě) compose 的配置文件,語(yǔ)法與 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

版權(quán)聲明:本文為博主原創(chuàng)文章,未經(jīng)博主允許不得轉(zhuǎn)載。