teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

1

Dockerfileで検証した内容を追加

2020/05/12 13:41

投稿

退会済みユーザー
title CHANGED
File without changes
body CHANGED
@@ -65,44 +65,44 @@
65
65
 
66
66
  ```ini
67
67
 
68
- ---> Running in 99cd35a01be3
68
+ ---> Running in 99cd35a01be3
69
- Removing intermediate container 99cd35a01be3
69
+ Removing intermediate container 99cd35a01be3
70
- ---> db6ccf021215
70
+ ---> db6ccf021215
71
- Step 3/9 : RUN apt-get update
71
+ Step 3/9 : RUN apt-get update
72
- ---> Running in 891ade3e6454
72
+ ---> Running in 891ade3e6454
73
- Err:1 http://security.debian.org/debian-security buster/updates InRelease
73
+ Err:1 http://security.debian.org/debian-security buster/updates InRelease
74
- Temporary failure resolving 'security.debian.org'
74
+ Temporary failure resolving 'security.debian.org'
75
- Err:2 http://deb.debian.org/debian buster InRelease
75
+ Err:2 http://deb.debian.org/debian buster InRelease
76
- Temporary failure resolving 'deb.debian.org'
76
+ Temporary failure resolving 'deb.debian.org'
77
- Err:3 http://deb.debian.org/debian buster-updates InRelease
77
+ Err:3 http://deb.debian.org/debian buster-updates InRelease
78
- Temporary failure resolving 'deb.debian.org'
78
+ Temporary failure resolving 'deb.debian.org'
79
- Reading package lists...
79
+ Reading package lists...
80
- W: Failed to fetch http://deb.debian.org/debian/dists/buster/InRelease Temporary failure resolving 'deb.debian.org'
80
+ W: Failed to fetch http://deb.debian.org/debian/dists/buster/InRelease Temporary failure resolving 'deb.debian.org'
81
- W: Failed to fetch http://security.debian.org/debian-security/dists/buster/updates/InRelease Temporary failure resolving 'security.debian.org'
81
+ W: Failed to fetch http://security.debian.org/debian-security/dists/buster/updates/InRelease Temporary failure resolving 'security.debian.org'
82
- W: Failed to fetch http://deb.debian.org/debian/dists/buster-updates/InRelease Temporary failure resolving 'deb.debian.org'
82
+ W: Failed to fetch http://deb.debian.org/debian/dists/buster-updates/InRelease Temporary failure resolving 'deb.debian.org'
83
- W: Some index files failed to download. They have been ignored, or old ones used instead.
83
+ W: Some index files failed to download. They have been ignored, or old ones used instead.
84
- Removing intermediate container 891ade3e6454
84
+ Removing intermediate container 891ade3e6454
85
- ---> ce8c52f90080
85
+ ---> ce8c52f90080
86
- Step 4/9 : RUN apt-get install -y libpq-dev libjpeg-dev libpng-dev vim nodejs sendmail git libzip-dev unzip
86
+ Step 4/9 : RUN apt-get install -y libpq-dev libjpeg-dev libpng-dev vim nodejs sendmail git libzip-dev unzip
87
- ---> Running in 5e818608a902
87
+ ---> Running in 5e818608a902
88
- Reading package lists...
88
+ Reading package lists...
89
- Building dependency tree...
89
+ Building dependency tree...
90
- Reading state information...
90
+ Reading state information...
91
- Package git is not available, but is referred to by another package.
91
+ Package git is not available, but is referred to by another package.
92
- This may mean that the package is missing, has been obsoleted, or
92
+ This may mean that the package is missing, has been obsoleted, or
93
- is only available from another source
93
+ is only available from another source
94
-
94
+
95
- E: Unable to locate package libpq-dev
95
+ E: Unable to locate package libpq-dev
96
- E: Unable to locate package libjpeg-dev
96
+ E: Unable to locate package libjpeg-dev
97
- E: Unable to locate package libpng-dev
97
+ E: Unable to locate package libpng-dev
98
- E: Unable to locate package vim
98
+ E: Unable to locate package vim
99
- E: Unable to locate package nodejs
99
+ E: Unable to locate package nodejs
100
- E: Unable to locate package sendmail
100
+ E: Unable to locate package sendmail
101
- E: Package 'git' has no installation candidate
101
+ E: Package 'git' has no installation candidate
102
- E: Unable to locate package libzip-dev
102
+ E: Unable to locate package libzip-dev
103
- E: Unable to locate package unzip
103
+ E: Unable to locate package unzip
104
104
  ERROR: Service 'line-app-server' failed to build: The command '/bin/sh -c apt-get install -y libpq-dev libjpeg-dev libpng-dev vim nodejs sendmail git libzip-dev unzip' returned a non-zero code:
105
- 100
105
+ 100
106
106
  ```
107
107
 
108
108
 
@@ -115,8 +115,12 @@
115
115
  ただ
116
116
 
117
117
  ```ini
118
+
118
- docker container create --name php-server -it --net host -p 8080:80 php:latest /bin/bash
119
+ docker container create --name php-server -it --net host -p 8080:80 php:latest /bin/bash
120
+
119
121
  ```
122
+
123
+
120
124
  上記の様に、--net hostというパラメータをつけて phpコンテナ単体で実行し
121
125
  コンテナ内で apt-get updateすると問題なく apt-get update が実行されました。
122
126
 
@@ -124,4 +128,44 @@
124
128
  apt-get update できません。
125
129
 
126
130
 
127
- どなたか解決方法がわかる方、ご存知のかたご教授くださると幸いです。
131
+ どなたか解決方法がわかる方、ご存知のかたご教授くださると幸いです。
132
+
133
+
134
+
135
+ 実行しているDockerfileは以下のとおりです
136
+
137
+ ```ini
138
+
139
+ FROM php:7.2.19-fpm
140
+
141
+ # (1)
142
+ RUN apt-get update
143
+ # (2)
144
+ RUN apt-get install -y libpq-dev libjpeg-dev libpng-dev vim nodejs sendmail git libzip-dev unzip
145
+ # (3)
146
+ RUN docker-php-ext-configure gd --with-jpeg-dir=/usr/include/ --with-png-dir=/usr/include/
147
+ # (4)
148
+ RUN docker-php-ext-install gd opcache pdo_pgsql pdo_mysql
149
+
150
+
151
+ # git動作環境で 非SSLでも通信できるように設定
152
+ RUN git config --global http.sslVerify false
153
+ # Composerのインストール
154
+ COPY --from=composer /usr/bin/composer /usr/bin/composer
155
+
156
+ WORKDIR /var/www/html
157
+
158
+ ```
159
+
160
+
161
+ 検証処理(1)
162
+ 上記の#(1)~#(4)のRUNコマンドをコメントアウトしてほぼコンテナイメージのままビルドして、dokcer container exec -it コンテナ名 /bin/bash でコンテナ内に入って
163
+ apt-get update してもエラーで帰ってきました。
164
+
165
+ 検証処理(2)
166
+ ただ、docker-compose.ymlに
167
+ network_mode: "host"を追加した状態で
168
+ 同じく
169
+ 上記の#(1)~#(4)のRUNコマンドをコメントアウトしてほぼコンテナイメージのままビルドして、dokcer container exec -it コンテナ名 /bin/bash でコンテナ内に入って
170
+ apt-get update した場合はうまく updateがはしりました。
171
+ ただDockerfileにRUN apt-get updateを記述した場合は、同様にDNS関連のエラーのような ものが発生します。