Docker Practice 3: fig builds mediawiki and dockermediawiki
Fig, fig. The fig project originated from docker and can be considered as a tool to quickly build a Docker-based isolated development environment.
1. Install fig
$ mkdir docker; cd docker$ curl -L https://github.com/docker/fig/releases/download/1.0.1/fig-`uname -s`-`uname -m` > fig$ sudo chmod +x fig; sudo mv /usr/local/bin/
2. Build mediawiki
Using a personal image, github address: https://github.com/bopjiang/wikimedia-docker
Run the following command in the docker directory:
$ git clone https://github.com/bopjiang/wikimedia-docker.git$ cd wikimedia-docker$ fig up -d
At this time, two containers start:
r$ docker psCONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES21182a060c17 nickstenning/mediawiki:latest "/usr/bin/mediawiki- 7 hours ago Up 7 hours 0.0.0.0:8880->80/tcp wikimediadocker_wiki2_1 728ec09c3552 mysql:5.7.5 "/entrypoint.sh mysq 7 hours ago Up 7 hours 3306/tcp wikimediadocker_db_1
Iii. fig. yml
Fig. yml is used to configure the specific content of image building. The content of fig. yml in this wiki is in the wikimedia-docker directory. The content is as follows:
wiki2: image: 'nickstenning/mediawiki' ports: - "8880:80" links: - db:database volumes: - /data/wiki2:/datadb: image: "mysql:5.7.5" expose: - "3306" environment: - MYSQL_ROOT_PASSWORD=defaultpass
Image: used to specify the image. If the image does not exist locally, fig will try to use the remote pull image.
Ports: exposed port.
Links: connect to the container in other services.
Volumes: volume mount path. The/data/directory in the container is mounted to/data/wiki2 of the host. After the wiki configuration is complete, place the LocalSettings. php file in the/data/wiki2 directory of the host.
Expose: it is also an exposed port. The difference with ports is that the port is not published to the host machine and only accessed by the connected service.
Environment: Set environment variables.
Iv. wiki Configuration
Enter localhost: 8880 in the browser. The configuration page will be displayed when the system is started for the first time. Generate the LocalSettings. php file. You can also configure it directly in this configuration file.
5. wiki usage skills
1. configuration in the left-side Navigation Pane
Log on as an administrator and enter MediaWiki: sidebar in the search box.
After entering the configuration page, you can edit it. For example:
<Pre>
Navigation
Http: // 192.168.0.111: 8880/index. php? Title = Category: XXX | XXX
Mainpage | mainpage-description
Portal-url | portal
</Pre>
3. Category
Add the "category" label at the end of the article to add this article to the xxx category. One article can be added to multiple categories.
For example: [[category: XXX]
4. New article
Enter the name of your article in Search to Edit.
5. line feed
You can use the br label to wrap a line. <Br>
A blank line also has a line feed effect.
6. pre Tag surrounding source code
For example:
<Pre>
Private int mSize;
</Pre>
6. Save container and import
sudo docker commit 9ab6e234c9ba linc-wikisudo docker images REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE linc-wiki latest b5a1e34b01c2 14 seconds ago 689.7 MBsudo docker export 9ab6e234c9ba > /home/linc/docker/images-bk/linc-wiki-export.tarsudo docker save linc-wiki > ../images-bk/linc-wiki-save.tar$ du -sh *495M linc-wiki-export.tar672M linc-wiki-save.tarsudo cat /home/linc/docker/images-bk/linc-wiki-export.tar | sudo docker import - docker_hgwebsudo docker load --input ../images-bk/linc-wiki-save.tar
Appendix:
1. fig Error Reporting and Solution
Fig running error:
$ fig upCouldn't connect to Docker daemon at http:/ - is it running?If it's at a non-standard location, specify the URL with the DOCKER_HOST environment variable.
Fix it:
1) Change the DOCKER_OPTS in /etc/default/docker to:DOCKER_OPTS="-H tcp://127.0.0.1:4243 -H unix:///var/run/docker.sock"2) Restart dockersudo restart docker3) Make sure that docker is running on localhost:4243 $ netstat -ant |grep 4243tcp 0 0 127.0.0.1:4243 0.0.0.0:* LISTEN4) Set DOCKER_HOST (.bashrc)export DOCKER_HOST=tcp://localhost:4243$ echo $DOCKER_HOSTtcp://localhost:4243
Refer:
Dockerpool.com/static/books/docker_practice/fig/yml_ref.html