ãDockerããå©ç¨ãã¦ä½ãã¢ãã³ãªPHPã®éçºç°å¢
ãã¾ããã§ãããDocker使ã£ã¦ãã¾ããï¼
ã¢ã¼ãã£ã¹ã§ãå°ãåããDockerãå©ç¨ãã¦éçºããããã«ãªãã¾ãããDockerããåãã§ã¯ãªãæ¹ã«ç°¡åã«èª¬æãã¦ããã¾ãã¨ãDockerã¯ããã軽éãªä»®æ³åç°å¢ã§ãã
ä»®æ³åæè¡ã¨ããã°VMwareãVirtualBoxãªã©ãæåã§ã¢ã¼ãã£ã¹ã§ãå©ç¨ãã¦ãã¾ããããããã®ä»®æ³åæè¡ã¯ãã·ã³ã¬ãã«ã§ã®ä»®æ³åãè¡ãã¾ãããDockerã¯OSã¬ãã«ã§ã®ä»®æ³åãè¡ãã¾ãã
Dockerã§ã®ä»®æ³åç°å¢ã¯ããã¹ãã®Linuxã«ã¼ãã«ãå
±æãã¦ããã®ã§ãªã¼ãããããå°ãããæ¢åã®ä»®æ³åæè¡ã¨æ¯è¼ããå ´åã軽ãã¦éããã¨ãç¹å¾´ã§ãã
ãããªéçºãæãDockerãªã®ã§ãããå°ãã¨ã£ã¤ãã«ããé¨åãããã®ã§ãPHP7+Apacheã§å¿
è¦æä½éã®éçºç°å¢ãä½ãæ¹æ³ãç´¹ä»ãã¦ã¿ããã¨æãã¾ãã
ããããå
ã®å
容ã¯ããã¹ãOSå´ã«Dockerãã¤ã³ã¹ãã¼ã«æ¸ã¿ã§ããäºãåæã«ãã¦ãã¾ããDockerãã¤ã³ã¹ãã¼ã«ããã¦ããªãå ´åã¯ãæ¸ç±ããµã¤ããåèã«ãã¦ã¤ã³ã¹ãã¼ã«ãã¦ãã ããã
INDEX
Docker Hubããå ã¨ãªãã¤ã¡ã¼ã¸ãé¸ã¶
Dockerã§ã³ã³ããï¼ä»®æ³åç°å¢ï¼ãæ§ç¯ããããã«ã¯ãã³ã³ããã®å
ã¨ãªãã¤ã¡ã¼ã¸ãå¿
è¦ã§ãã
ã¤ã¡ã¼ã¸ãèªåã§æ§ç¯ãããã¨ãã§ãã¾ãããå
¬å¼ã®Docker Hubã§ã¯æ§ã
ãªã¤ã¡ã¼ã¸ãå
¬éããã¦ãã¾ãã
ä»åã¯æ軽ã«æ§ç¯ãããã®ã§å
¬å¼ã®ã¤ã¡ã¼ã¸ãå©ç¨ãã¾ãã
ä¸è¨ã®URLãPHPã®å
¬å¼ãªãã¸ããªã§ãã
ãSupported tags and respective Dockerfile linksãã®ä¸é¨ã«ãºã©ãºã©ã¨PHPã®ãã¼ã¸ã§ã³ããããã®ãæ¸ããã¦ããã¨æãã¾ãããããã¯tagã¨ãã°ãããã®ã§ãã¤ã¡ã¼ã¸ã®å 容ã表ãã¦ãã¾ãã
ä»åã¯ãPHP7.0.21ã¨Apacheãä¸ã¤ã®ã³ã³ããã«å«ã¾ãã¦ããã7.0.21-apacheãã使ããã¨ã«ãã¾ãã
ã¤ã¡ã¼ã¸ããã«ãããããã®Dockerfileãä½ã
使ãã¤ã¡ã¼ã¸ã決å®ããã®ã§ãå®éã«ãã®ã¤ã¡ã¼ã¸ãã¤ãã£ã¦ã³ã³ãããæ§ç¯ãã¾ãã
ã¾ããé©å½ãªãã£ã¬ã¯ããªï¼php7-apacheï¼ãä½æãã¦ããã®ä¸ã«ãDockerfileããä½æãã¾ãã
$ mkdir php7-apache
$ cd php7-apache/
$ touch Dockerfile
Dockerfileã«ä»¥ä¸ã®å 容ãæ¸ãè¾¼ã¿ã¾ãã
FROM php:7.0.21-apache
RUN docker-php-ext-install -j$(nproc) pdo_mysql
FROMã¯ããã¼ã¹ã¨ãªãã¤ã¡ã¼ã¸ã¨ã¿ã°ãæå®ãã¦ãã¾ãã
RUNã¯ããã«ãæã«å®è¡ãããã³ãã³ãã§ãã
PHPã¢ã¸ã¥ã¼ã«ã¯ãdocker-php-ext-installã®å¾ãã«è¿½å ãã¦æå®ãã¾ãã
ä»åã¯ä½¿ãäºå®ã¯ãªãã§ãããã¤ã³ã¹ãã¼ã«ã®ç¢ºèªç¨ã«pdo_mysqlã追å ãã¦ãã¾ãã
ãdocker buildãã³ãã³ããå®è¡ããã¨ãã«ããéå§ããã¦ãèªåçã«æå®ããã¤ã¡ã¼ã¸ããã¦ã³ãã¼ãããã¾ãã
$ docker build ./ -t php7_apache
ã-tãã¯ããã«ãããã¤ã¡ã¼ã¸ã«ã¤ãããªãã¸ããªåã¨ã¿ã°ãæå®ãã¾ãã
ãdocker imagesãã³ãã³ããå®è¡ãã¦ãã«ããããã¤ã¡ã¼ã¸ã確èªãã¦ã¿ã¾ãã
$ docker images
REPOSITORYÂ Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â TAGÂ Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â IMAGE IDÂ Â Â Â Â Â Â Â Â Â Â Â CREATEDÂ Â Â Â Â Â Â Â Â Â Â Â SIZE
php7_apache                                latest              8ae1f1661332        16 hours ago        389.6 MB
ã¤ã¡ã¼ã¸ããã«ãã§ããã®ã確èªã§ãã¾ããï¼
ãã¼ã¿ã®æ°¸ç¶åã®ããã«ãã¦ã³ãç¨ã®ãã£ã¬ã¯ããªãã¤ãã
ã³ã³ããã®ä¸ã®ãã¡ã¤ã«ã¯æ°¸ç¶åãããªãã®ã§ããã¹ãå´ã®ãã£ã¬ã¯ããªãã³ã³ããå´ã«ãã¦ã³ãããå¿
è¦ãããã¾ãã
åããã£ã¬ã¯ããªå
ã«ãã¦ã³ãç¨ã®ãã£ã¬ã¯ããªãä½æãã¦ããã¾ãã
$ mkdir html
ãã®ãã£ã¬ã¯ããªãã³ã³ããå´ã®/var/www/htmlã«ãã¦ã³ããã¾ããç¾å¨ã®ãã£ã¬ã¯ããªæ§é ã¯ä»¥ä¸ã®ããã«ãªã£ã¦ãã¾ãã
php7-apahce — Dockerfile — html |
ã³ã³ãããèµ·åãã¦ã¿ã
æºåãã§ããã®ã§ããdocker runãã³ãã³ããå®è¡ãã¦ã³ã³ãããèµ·åãã¾ãã
$ docker run -d -p 80:80 -v /home/hoge/php7-apache/html:/var/www/html --name php7-apache php7_apache
ã-dãã¯ãããã¯ã°ã©ã¦ã³ãã§å®è¡ãããªãã·ã§ã³ã§ãã
ã-pãã¯ããã¼ãã®è¨å®ã§ããã¹ãå´:ã²ã¹ãï¼ã³ã³ããï¼å´ã§æå®ãã¾ãã
ã-vãã¯ãvolumeã®æå®ã§ããã¦ã³ãããããã£ã¬ã¯ããªãããã¹ãå´ã®ãã¹:ã²ã¹ãå´ã®ãã¹ã§æå®ãã¾ãã
ã–nameãã¯ãã³ã³ããã«ãphp7-apacheãã¨ããååãæå®ãã¦ãã¾ããï¼ååãæå®ãã¦ããªãã¨èªåçã«ä»ãããã¾ããï¼
æå¾ã®ãphp7_apacheãã§å
ç¨ãã«ãããã¤ã¡ã¼ã¸åï¼ãªãã¸ããªåï¼ãæå®ãã¾ãã
ã³ã³ãããèµ·åãã¦ããã®ã確èªããããã«ããdocker psãã³ãã³ããå®è¡ãã¦ã¿ã¾ãã
$ docker ps
CONTAINER IDÂ Â Â Â Â Â Â Â IMAGEÂ Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â COMMANDÂ Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â CREATEDÂ Â Â Â Â Â Â Â Â Â Â Â STATUSÂ Â Â Â Â Â Â Â Â Â Â Â Â Â PORTSÂ Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â NAMES
8a4eb62b45ae        php7_apache        "docker-php-entrypoin"  3 minutes ago      Up 3 minutes        0.0.0.0:80->80/tcp  php7-apache
åé¡ãªãèµ·åãã¦ãã¾ããï¼
ã³ã³ãã³ããç½®ãã¦åä½ç¢ºèªãã
åä½ç¢ºèªã®ããã«ãphpinfoé¢æ°ãå®è¡ããphpinfo.phpãã³ã³ããå
ã«ç½®ãã¦å®è¡ãã¦ã¿ã¾ãã
ãã¹ãå´ã®volumeã«æå®ããhtmlãã£ã¬ã¯ããªå
ã«ãã¡ã¤ã«ãä½æãã¾ãã
$ touch phpinfo.php
é©å½ãªã¨ãã£ã¿ã§ä»¥ä¸ã®å 容ãæ¸ãè¾¼ã¿ã¾ãã
<?php
phpinfo();
ãã©ã¦ã¶ã§ãã¹ãå´ã®IPãæå®ããã¨phpinfoã®å®è¡çµæã表示ããã¾ãã
以ä¸ã§ç°¡åãªéçºç°å¢ãæ§ç¯ã§ãã¾ããã
ãããã«
Dockerã®ã¡ãªããã¨ãã¡ãªããã確èªãã¦ããã¾ãã
ã¡ãªãã
- ã²ã¹ãOSå´ã«ããããã«ã¼ãã«ãæã¤å¿ è¦ãç¡ãããããªã½ã¼ã¹ã®æ¶è²»ãç¯ç´ã§ãããï¼è»½ãï¼
- ã²ã¹ãOSå´ã§ã«ã¼ãã«ãç«ã¡ä¸ããå¿ è¦ããªãã®ã§ãã²ã¹ãOSã®èµ·åãé«éãï¼éãï¼
ãã¡ãªãã
- ãã¹ãã¨éã種é¡ã®OSãã²ã¹ãã«å©ç¨ã§ããªããï¼Linuxã®ã²ã¹ãã«Windowsã®ãã¹ããè¼ãããã¨ã¯ã§ããªããï¼
- ã«ã¼ãã«ã¯å ±æãããã®ã§åå¥ã®è¨å®ãã§ããªãã
ã¢ã¼ãã£ã¹ã§ã¯ãéçºæã¯ãã¡ããããã¼ã¸ã§ã³ãç°ãªãããã«ã¦ã§ã¢ç°å¢ã§ã®æ¤è¨¼ããèªåãã¹ãã®å®è¡ç°å¢ã¨ãã¦Dockerãå©ç¨ãã¦éçºå¹çãé«ãã¦ãã¾ãã
ãã®è¨äºãæ¸ãã人
- åµé æ§ãæ大éã«çºæ®ããã¨ã¨ãã«ãã¤ã³ã¿ã¼ãããã«ä»£è¡¨ãããITãæ´»ç¨ããã¿ããªã®çæ´»ã便å©ã§ãè±ãã§ã楽ãããã®ã«ãªããããªãµã¼ãã¹ãã³ã³ãã³ããèããåµãåºãæä¾ãã¦ãã¾ãã
ãã®å·çè ã®ææ°è¨äº
- 2022å¹´10æ24æ¥WEBGraphQLãµã¼ããæ§ç¯ããããã®Goã©ã¤ãã©ãªãgqlgenãã使ã£ã¦GraphQLãµã¼ãã¼ãæ§ç¯ãã¦ã¿ã
- 2022å¹´8æ25æ¥WEBGo WebAssemblyã§ãã©ã¦ã¶ä¸ã§Goãå®è¡ãã ãã®3 Javascriptå´ããGoã®é¢æ°ãå¼ã³åºã
- 2022å¹´6æ21æ¥WEBGo WebAssemblyã§ãã©ã¦ã¶ä¸ã§Goãå®è¡ãã ãã®2 Goå´ããJavascriptãæä½ãã
- 2022å¹´4æ25æ¥WEBGoã®ã³ã¼ããWebAssenblyã«ã³ã³ãã¤ã«ãã¦ãã©ã¦ã¶ä¸ã§Goãå®è¡ãã
é¢é£è¨äº
ææ°è¨äº
FOLLOW US
ææ°ã®æ å ±ããå±ããã¾ã
- facebookã§ãã©ãã¼
- Twitterã§ãã©ãã¼
- Feedlyã§ãã©ãã¼