[{"data":1,"prerenderedAt":629},["ShallowReactive",2],{"article-stuck-on-docker-centos8":3},{"id":4,"title":5,"body":6,"category":617,"createdAt":619,"description":5,"extension":620,"index":621,"meta":622,"navigation":69,"path":623,"publish":69,"seo":624,"series":621,"seriesTitle":621,"stem":625,"tag":626,"thumbnail":621,"updatedAt":621,"__hash__":628},"articles\u002Farticles\u002Fstuck-on-docker-centos8.md","Docker でcentos8+Apache2.4 の環境を作ろうとして詰まった",{"type":7,"value":8,"toc":613},"minimark",[9,13,22,25,28,38,43,46,176,179,208,211,238,245,358,365,369,376,385,388,556,559,590,600,609],[10,11,12],"p",{},"この記事はosからイメージを指定して作ろうとして、FROM centos から構築して",[10,14,15,19],{},[16,17,18],"code",{},"Failed to connect to bus: No such file or directory docker",[16,20,21],{},"System has not been booted with systemd as init system (PID 1). Can't operate. Failed to connect to bus: Host is down",[10,23,24],{},"というエラーで詰まってブチ切れそうになっている人は以下の方法を確認してみてください。原因は「公式に解決法がありました」から述べていきます。",[10,26,27],{},"この記事で使用したOSとdockerのバージョン",[29,30,31,35],"ul",{},[32,33,34],"li",{},"docker：19.03.13",[32,36,37],{},"maxOS Catalina 10.15.5",[39,40,42],"h2",{"id":41},"dockerfileからcentos8apache24の環境作ろうとした","Dockerfileからcentos8+apache2.4の環境作ろうとした",[10,44,45],{},"apacheのイメージを入れるとosがUbuntuだったりで、できたらosから指定したいなーと思ってcenots8の環境にapacheを入れて行こうと思い以下のようにDockerfileを記述",[47,48,54],"pre",{"className":49,"code":50,"filename":51,"language":52,"meta":53,"style":53},"language-dockerfile shiki shiki-themes material-theme-ocean","FROM centos:8\n\nRUN \u002Fbin\u002Fcp \u002Fusr\u002Fshare\u002Fzoneinfo\u002FAsia\u002FTokyo \u002Fetc\u002Flocaltime\n\nRUN yum install -y epel-release && yum clean all\n\nRUN rpm -ivh http:\u002F\u002Fftp.riken.jp\u002FLinux\u002Fremi\u002Fenterprise\u002Fremi-release-8.rpm\n\nRUN yum -y update && yum clean all\n\nRUN yum -y install httpd && yum clean all\n\nRUN yum -y install php74-php php74-php-mysqli php74-php-gd php74-php-mbstring php74-php-opcache php74-php-xml php74-php-pear php74-php-devel php74-php-pecl-imagick php74-php-pecl-imagick-devel php74-php-pecl-zip\n\nRUN ln \u002Fusr\u002Fbin\u002Fphp74 \u002Fusr\u002Fbin\u002Fphp\n\nRUN chown -R apache:apache \u002Fvar\u002Fwww\u002Fhtml\n\nRUN systemctl enable php74-php-fpm\n\nRUN systemctl enable httpd \n","Dockerfile","dockerfile","",[16,55,56,64,71,77,82,88,93,99,104,110,115,121,126,132,137,143,148,154,159,165,170],{"__ignoreMap":53},[57,58,61],"span",{"class":59,"line":60},"line",1,[57,62,63],{},"FROM centos:8\n",[57,65,67],{"class":59,"line":66},2,[57,68,70],{"emptyLinePlaceholder":69},true,"\n",[57,72,74],{"class":59,"line":73},3,[57,75,76],{},"RUN \u002Fbin\u002Fcp \u002Fusr\u002Fshare\u002Fzoneinfo\u002FAsia\u002FTokyo \u002Fetc\u002Flocaltime\n",[57,78,80],{"class":59,"line":79},4,[57,81,70],{"emptyLinePlaceholder":69},[57,83,85],{"class":59,"line":84},5,[57,86,87],{},"RUN yum install -y epel-release && yum clean all\n",[57,89,91],{"class":59,"line":90},6,[57,92,70],{"emptyLinePlaceholder":69},[57,94,96],{"class":59,"line":95},7,[57,97,98],{},"RUN rpm -ivh http:\u002F\u002Fftp.riken.jp\u002FLinux\u002Fremi\u002Fenterprise\u002Fremi-release-8.rpm\n",[57,100,102],{"class":59,"line":101},8,[57,103,70],{"emptyLinePlaceholder":69},[57,105,107],{"class":59,"line":106},9,[57,108,109],{},"RUN yum -y update && yum clean all\n",[57,111,113],{"class":59,"line":112},10,[57,114,70],{"emptyLinePlaceholder":69},[57,116,118],{"class":59,"line":117},11,[57,119,120],{},"RUN yum -y install httpd && yum clean all\n",[57,122,124],{"class":59,"line":123},12,[57,125,70],{"emptyLinePlaceholder":69},[57,127,129],{"class":59,"line":128},13,[57,130,131],{},"RUN yum -y install php74-php php74-php-mysqli php74-php-gd php74-php-mbstring php74-php-opcache php74-php-xml php74-php-pear php74-php-devel php74-php-pecl-imagick php74-php-pecl-imagick-devel php74-php-pecl-zip\n",[57,133,135],{"class":59,"line":134},14,[57,136,70],{"emptyLinePlaceholder":69},[57,138,140],{"class":59,"line":139},15,[57,141,142],{},"RUN ln \u002Fusr\u002Fbin\u002Fphp74 \u002Fusr\u002Fbin\u002Fphp\n",[57,144,146],{"class":59,"line":145},16,[57,147,70],{"emptyLinePlaceholder":69},[57,149,151],{"class":59,"line":150},17,[57,152,153],{},"RUN chown -R apache:apache \u002Fvar\u002Fwww\u002Fhtml\n",[57,155,157],{"class":59,"line":156},18,[57,158,70],{"emptyLinePlaceholder":69},[57,160,162],{"class":59,"line":161},19,[57,163,164],{},"RUN systemctl enable php74-php-fpm\n",[57,166,168],{"class":59,"line":167},20,[57,169,70],{"emptyLinePlaceholder":69},[57,171,173],{"class":59,"line":172},21,[57,174,175],{},"RUN systemctl enable httpd\n",[10,177,178],{},"php入っていますがとりあえず上のような感じで必要なものを入れて、apacheを常にONにすれば行けるだろ思い、ビルドする",[47,180,184],{"className":181,"code":182,"language":183,"meta":53,"style":53},"language-bash shiki shiki-themes material-theme-ocean","$ docker build -t centos_apche:1.0 .\n","bash",[16,185,186],{"__ignoreMap":53},[57,187,188,192,196,199,202,205],{"class":59,"line":60},[57,189,191],{"class":190},"s5Dmg","$",[57,193,195],{"class":194},"sfyAc"," docker",[57,197,198],{"class":194}," build",[57,200,201],{"class":194}," -t",[57,203,204],{"class":194}," centos_apche:1.0",[57,206,207],{"class":194}," .\n",[10,209,210],{},"ビルドは普通に成功しました。イメージが作られたのを確認していざコンテナを起動。",[47,212,214],{"className":181,"code":213,"language":183,"meta":53,"style":53},"docker run -t -d -p 9000:80 centos_apche:1.0\n",[16,215,216],{"__ignoreMap":53},[57,217,218,221,224,226,229,232,235],{"class":59,"line":60},[57,219,220],{"class":190},"docker",[57,222,223],{"class":194}," run",[57,225,201],{"class":194},[57,227,228],{"class":194}," -d",[57,230,231],{"class":194}," -p",[57,233,234],{"class":194}," 9000:80",[57,236,237],{"class":194}," centos_apche:1.0\n",[10,239,240,241,244],{},"しかし localhost:9000 にアクセスすると「データが送信されませんでした」と真っ黒（chrome）。",[16,242,243],{},"docker ps"," で稼働状態を調べてもコンテナはきちんと動いている。つまりコンテナの中で何か起きている。",[47,246,248],{"className":181,"code":247,"language":183,"meta":53,"style":53},"docker exec -it {container_id or name} \u002Fbin\u002Fbash\n...\n[root@32212888398b \u002F]# \n[root@32212888398b \u002F]# systemctl httpd status \nSystem has not been booted with systemd as init system (PID 1). Can't operate. \nFailed to connect to bus: Host is down\n",[16,249,250,272,278,294,305,353],{"__ignoreMap":53},[57,251,252,254,257,260,263,266,269],{"class":59,"line":60},[57,253,220],{"class":190},[57,255,256],{"class":194}," exec",[57,258,259],{"class":194}," -it",[57,261,262],{"class":194}," {container_id",[57,264,265],{"class":194}," or",[57,267,268],{"class":194}," name}",[57,270,271],{"class":194}," \u002Fbin\u002Fbash\n",[57,273,274],{"class":59,"line":66},[57,275,277],{"class":276},"sdLwU","...\n",[57,279,280,284,288,291],{"class":59,"line":73},[57,281,283],{"class":282},"sAklC","[",[57,285,287],{"class":286},"s0W1g","root@32212888398b \u002F",[57,289,290],{"class":282},"]",[57,292,293],{"class":286},"# \n",[57,295,296,298,300,302],{"class":59,"line":79},[57,297,283],{"class":282},[57,299,287],{"class":286},[57,301,290],{"class":282},[57,303,304],{"class":286},"# systemctl httpd status \n",[57,306,307,310,313,316,319,322,325,328,331,334,337,340,344,347,350],{"class":59,"line":84},[57,308,309],{"class":190},"System",[57,311,312],{"class":194}," has",[57,314,315],{"class":194}," not",[57,317,318],{"class":194}," been",[57,320,321],{"class":194}," booted",[57,323,324],{"class":194}," with",[57,326,327],{"class":194}," systemd",[57,329,330],{"class":194}," as",[57,332,333],{"class":194}," init",[57,335,336],{"class":194}," system",[57,338,339],{"class":286}," (PID ",[57,341,343],{"class":342},"sx098","1",[57,345,346],{"class":286},"). Can",[57,348,349],{"class":282},"'",[57,351,352],{"class":194},"t operate. \n",[57,354,355],{"class":59,"line":90},[57,356,357],{"class":194},"Failed to connect to bus: Host is down\n",[10,359,360,361,364],{},"「は？」とりあえずhttpdが動いていないそうな上に「Host is down」とos自体がダメと言うことか？",[16,362,363],{},"systemctl","だけ打ってもエラーしか出ない。",[39,366,368],{"id":367},"公式に解決法がありました","公式に解決法がありました。",[10,370,371,372,375],{},"いろいろ調べましたが ",[16,373,374],{},"systemd"," を起動する方法がcentos7、centos:latest（つまり８）ではデフォルトでアクティブにならず一工夫必要だそうです。",[10,377,378],{},[379,380,384],"a",{"href":381,"rel":382},"https:\u002F\u002Fhub.docker.com\u002F_\u002Fcentos",[383],"nofollow","公式ドキュメント",[10,386,387],{},"私も詳しい仕組みまではわからないのですが、まずDockerfileを以下のように追記します。",[47,389,391],{"className":49,"code":390,"filename":51,"language":52,"meta":53,"style":53},"FROM centos:8\n#ここから\nENV container docker\nRUN (cd \u002Flib\u002Fsystemd\u002Fsystem\u002Fsysinit.target.wants\u002F; for i in *; do [ $i == \\\nsystemd-tmpfiles-setup.service ] || rm -f $i; done); \\\nrm -f \u002Flib\u002Fsystemd\u002Fsystem\u002Fmulti-user.target.wants\u002F*;\\\nrm -f \u002Fetc\u002Fsystemd\u002Fsystem\u002F*.wants\u002F*;\\\nrm -f \u002Flib\u002Fsystemd\u002Fsystem\u002Flocal-fs.target.wants\u002F*; \\\nrm -f \u002Flib\u002Fsystemd\u002Fsystem\u002Fsockets.target.wants\u002F*udev*; \\\nrm -f \u002Flib\u002Fsystemd\u002Fsystem\u002Fsockets.target.wants\u002F*initctl*; \\\nrm -f \u002Flib\u002Fsystemd\u002Fsystem\u002Fbasic.target.wants\u002F*;\\\nrm -f \u002Flib\u002Fsystemd\u002Fsystem\u002Fanaconda.target.wants\u002F*;\nVOLUME [ \"\u002Fsys\u002Ffs\u002Fcgroup\" ]\nCMD [\"\u002Fusr\u002Fsbin\u002Finit\"]\n#ここまで\nRUN \u002Fbin\u002Fcp \u002Fusr\u002Fshare\u002Fzoneinfo\u002FAsia\u002FTokyo \u002Fetc\u002Flocaltime\n\nRUN yum install -y epel-release && yum clean all\n\nRUN rpm -ivh http:\u002F\u002Fftp.riken.jp\u002FLinux\u002Fremi\u002Fenterprise\u002Fremi-release-8.rpm\n\nRUN yum -y update && yum clean all\n\nRUN yum -y install httpd && yum clean all\n\nRUN yum -y install php74-php php74-php-mysqli php74-php-gd php74-php-mbstring php74-php-opcache php74-php-xml php74-php-pear php74-php-devel php74-php-pecl-imagick php74-php-pecl-imagick-devel php74-php-pecl-zip\n\nRUN ln \u002Fusr\u002Fbin\u002Fphp74 \u002Fusr\u002Fbin\u002Fphp\n\nRUN chown -R apache:apache \u002Fvar\u002Fwww\u002Fhtml\n\nRUN systemctl enable php74-php-fpm\n\nRUN systemctl enable httpd \n",[16,392,393,397,402,407,412,417,422,427,432,437,442,447,452,457,462,467,471,475,479,483,487,491,496,501,506,511,516,521,526,531,536,541,546,551],{"__ignoreMap":53},[57,394,395],{"class":59,"line":60},[57,396,63],{},[57,398,399],{"class":59,"line":66},[57,400,401],{},"#ここから\n",[57,403,404],{"class":59,"line":73},[57,405,406],{},"ENV container docker\n",[57,408,409],{"class":59,"line":79},[57,410,411],{},"RUN (cd \u002Flib\u002Fsystemd\u002Fsystem\u002Fsysinit.target.wants\u002F; for i in *; do [ $i == \\\n",[57,413,414],{"class":59,"line":84},[57,415,416],{},"systemd-tmpfiles-setup.service ] || rm -f $i; done); \\\n",[57,418,419],{"class":59,"line":90},[57,420,421],{},"rm -f \u002Flib\u002Fsystemd\u002Fsystem\u002Fmulti-user.target.wants\u002F*;\\\n",[57,423,424],{"class":59,"line":95},[57,425,426],{},"rm -f \u002Fetc\u002Fsystemd\u002Fsystem\u002F*.wants\u002F*;\\\n",[57,428,429],{"class":59,"line":101},[57,430,431],{},"rm -f \u002Flib\u002Fsystemd\u002Fsystem\u002Flocal-fs.target.wants\u002F*; \\\n",[57,433,434],{"class":59,"line":106},[57,435,436],{},"rm -f \u002Flib\u002Fsystemd\u002Fsystem\u002Fsockets.target.wants\u002F*udev*; \\\n",[57,438,439],{"class":59,"line":112},[57,440,441],{},"rm -f \u002Flib\u002Fsystemd\u002Fsystem\u002Fsockets.target.wants\u002F*initctl*; \\\n",[57,443,444],{"class":59,"line":117},[57,445,446],{},"rm -f \u002Flib\u002Fsystemd\u002Fsystem\u002Fbasic.target.wants\u002F*;\\\n",[57,448,449],{"class":59,"line":123},[57,450,451],{},"rm -f \u002Flib\u002Fsystemd\u002Fsystem\u002Fanaconda.target.wants\u002F*;\n",[57,453,454],{"class":59,"line":128},[57,455,456],{},"VOLUME [ \"\u002Fsys\u002Ffs\u002Fcgroup\" ]\n",[57,458,459],{"class":59,"line":134},[57,460,461],{},"CMD [\"\u002Fusr\u002Fsbin\u002Finit\"]\n",[57,463,464],{"class":59,"line":139},[57,465,466],{},"#ここまで\n",[57,468,469],{"class":59,"line":145},[57,470,76],{},[57,472,473],{"class":59,"line":150},[57,474,70],{"emptyLinePlaceholder":69},[57,476,477],{"class":59,"line":156},[57,478,87],{},[57,480,481],{"class":59,"line":161},[57,482,70],{"emptyLinePlaceholder":69},[57,484,485],{"class":59,"line":167},[57,486,98],{},[57,488,489],{"class":59,"line":172},[57,490,70],{"emptyLinePlaceholder":69},[57,492,494],{"class":59,"line":493},22,[57,495,109],{},[57,497,499],{"class":59,"line":498},23,[57,500,70],{"emptyLinePlaceholder":69},[57,502,504],{"class":59,"line":503},24,[57,505,120],{},[57,507,509],{"class":59,"line":508},25,[57,510,70],{"emptyLinePlaceholder":69},[57,512,514],{"class":59,"line":513},26,[57,515,131],{},[57,517,519],{"class":59,"line":518},27,[57,520,70],{"emptyLinePlaceholder":69},[57,522,524],{"class":59,"line":523},28,[57,525,142],{},[57,527,529],{"class":59,"line":528},29,[57,530,70],{"emptyLinePlaceholder":69},[57,532,534],{"class":59,"line":533},30,[57,535,153],{},[57,537,539],{"class":59,"line":538},31,[57,540,70],{"emptyLinePlaceholder":69},[57,542,544],{"class":59,"line":543},32,[57,545,164],{},[57,547,549],{"class":59,"line":548},33,[57,550,70],{"emptyLinePlaceholder":69},[57,552,554],{"class":59,"line":553},34,[57,555,175],{},[10,557,558],{},"そしてビルドは普通に行い、コンテナを立ち上げる際はボリュームともう一つオプションを指定します。",[47,560,562],{"className":181,"code":561,"language":183,"meta":53,"style":53},"docker run -v \u002Fsys\u002Ffs\u002Fcgroup:\u002Fsys\u002Ffs\u002Fcgroup:ro --privileged -t -d -p 9000:80 centos_apched:1.0\n",[16,563,564],{"__ignoreMap":53},[57,565,566,568,570,573,576,579,581,583,585,587],{"class":59,"line":60},[57,567,220],{"class":190},[57,569,223],{"class":194},[57,571,572],{"class":194}," -v",[57,574,575],{"class":194}," \u002Fsys\u002Ffs\u002Fcgroup:\u002Fsys\u002Ffs\u002Fcgroup:ro",[57,577,578],{"class":194}," --privileged",[57,580,201],{"class":194},[57,582,228],{"class":194},[57,584,231],{"class":194},[57,586,234],{"class":194},[57,588,589],{"class":194}," centos_apched:1.0\n",[10,591,592,595,596,599],{},[16,593,594],{},"-v \u002Fsys\u002Ffs\u002Fcgroup:\u002Fsys\u002Ffs\u002Fcgroup:ro","でファイルシステムをホストマシンからボリュームし、",[16,597,598],{},"--privileged","でコンテナにホストマシンのroot権限を与ます。どちらか片方が抜けてもいけません。",[10,601,602,603,605,606,608],{},"このオプションとボリュームを指定すると",[16,604,374],{},"が動きます。実際にコンテナに入っていくと",[16,607,363],{},"コマンドが実行されました。",[610,611,612],"style",{},"html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html pre.shiki code .s5Dmg, html code.shiki .s5Dmg{--shiki-default:#FFCB6B}html pre.shiki code .sfyAc, html code.shiki .sfyAc{--shiki-default:#C3E88D}html pre.shiki code .sdLwU, html code.shiki .sdLwU{--shiki-default:#82AAFF}html pre.shiki code .sAklC, html code.shiki .sAklC{--shiki-default:#89DDFF}html pre.shiki code .s0W1g, html code.shiki .s0W1g{--shiki-default:#BABED8}html pre.shiki code .sx098, html code.shiki .sx098{--shiki-default:#F78C6C}",{"title":53,"searchDepth":73,"depth":73,"links":614},[615,616],{"id":41,"depth":66,"text":42},{"id":367,"depth":66,"text":368},[618],"devstack","2020-11-27","md",null,{},"\u002Farticles\u002Fstuck-on-docker-centos8",{"title":5,"description":5},"articles\u002Fstuck-on-docker-centos8",[627,220],"infrastructure","yvD5JRk2N7X9ToHbPIm-hQQm0dyCSLPsVEnjEF9H-RE",1780987148828]