前提
alpine Linuxベースのdockerfileを書いている際
npm installがうまくいかなかった。
これを受けてapk updateコマンドの詳細情報を検索してみたが見つけられなかった。
環境
docker-machine上にて環境を構築しています。
起こった問題のソース
Dockerfile
1 2RUN apk add --update nodejs npm; \ 3 npm install -g browserify; \ 4 npm install -g babel-cli; \ 5 apk add git; 6
↑こちらのソースではDokcerコンテナが立ち上がらなかった。
以下のように修正したらコンテナが立ち上がってきた。
Dockerfile
1 2RUN apk add --update nodejs npm; \ 3 apk update; \ 4 npm install -g browserify; \ 5 apk update; \ 6 npm install -g babel-cli; \ 7 apk update; \ 8 apk add git; 9
疑問点
alpine linux における apk update コマンドがやっていることを詳しく知りたいです。
また今回のようにapk updateを書く必要があるのはDockerの仕様によるものなのか
AlpineLinuxの仕様によるものなのかもわかりましたらお願いいたします。
質問内容
もっとスマートに書きたいのですが
有効情報にたどり着けていない状況です。
ヒントだけでもいただけましたら嬉しく思います。
よろしくお願いいたします。
テスト2回目結果
Dockerfile
1 2FROM nginx:mainline-alpine 3RUN apk update; \ 4 apk add nodejs npm; \ 5 npm install -g browserify; \ 6 npm install -g babel-cli; \ 7 apk add git; 8WORKDIR /app 9EXPOSE 8080 10CMD nginx -g "daemon off;" 11
yml
1 2version: '3.7' 3services: 4 webserver: 5 build: ./ 6 container_name: nginx 7 tty: true 8 volumes: 9 - ./app:/app 10 ports: 11 - "8080:80" 12
shell
1 2$ docker-compose build --no-cache 3Building webserver 4Step 1/5 : FROM nginx:mainline-alpine 5mainline-alpine: Pulling from library/nginx 69d48c3bd43c5: Pull complete 7b6dac14ba0a9: Pull complete 8Status: Downloaded newer image for nginx:mainline-alpine 9Step 2/5 : RUN apk update; apk add nodejs npm; npm install -g browserify; npm install -g babel-cli; apk add git; 10fetch http://dl-cdn.alpinelinux.org/alpine/v3.10/main/x86_64/APKINDEX.tar.gz 11fetch http://dl-cdn.alpinelinux.org/alpine/v3.10/community/x86_64/APKINDEX.tar.gz 12v3.10.2-19 [http://dl-cdn.alpinelinux.org/alpine/v3.10/main] 13v3.10.2-2 [http://dl-cdn.alpinelinux.org/alpine/v3.10/community] 14OK: 10339 distinct packages available 15(1/8) Installing ca-certificates (20190108-r0) 16(2/8) Installing c-ares (1.15.0-r0) 17(3/8) Installing libgcc (8.3.0-r0) 18(4/8) Installing http-parser (2.9.2-r0) 19(5/8) Installing libstdc++ (8.3.0-r0) 20(6/8) Installing libuv (1.29.1-r0) 21(7/8) Installing nodejs (10.16.3-r0) 22(8/8) Installing npm (10.16.3-r0) 23Executing busybox-1.30.1-r2.trigger 24Executing ca-certificates-20190108-r0.trigger 25OK: 82 MiB in 45 packages 26npm ERR! code ENOTFOUND 27npm ERR! errno ENOTFOUND 28npm ERR! network request to https://registry.npmjs.org/cached-path-relative failed, reason: getaddrinfo ENOTFOUND registry.npmjs.org registry.npmjs.org:443 29npm ERR! network This is a problem related to network connectivity. 30npm ERR! network In most cases you are behind a proxy or have bad network settings. 31npm ERR! network 32npm ERR! network If you are behind a proxy, please make sure that the 33npm ERR! network 'proxy' config is set properly. See: 'npm help config' 34 35npm ERR! A complete log of this run can be found in: 36npm ERR! /root/.npm/_logs/2019-08-28T12_45_46_775Z-debug.log 37npm ERR! code ENOTFOUND 38npm ERR! errno ENOTFOUND 39npm ERR! network request to https://registry.npmjs.org/fs-readdir-recursive failed, reason: getaddrinfo ENOTFOUND registry.npmjs.org registry.npmjs.org:443 40npm ERR! network This is a problem related to network connectivity. 41npm ERR! network In most cases you are behind a proxy or have bad network settings. 42npm ERR! network 43npm ERR! network If you are behind a proxy, please make sure that the 44npm ERR! network 'proxy' config is set properly. See: 'npm help config' 45 46npm ERR! A complete log of this run can be found in: 47npm ERR! /root/.npm/_logs/2019-08-28debug.log 48(1/5) Installing nghttp2-libs (1.39.2-r0) 49(2/5) Installing libcurl (7.65.1-r0) 50(3/5) Installing expat (2.2.7-r0) 51(4/5) Installing pcre2 (10.33-r0) 52(5/5) Installing git (2.22.0-r0) 53Executing busybox-1.30.1-r2.trigger 54OK: 96 MiB in 50 packages 55Removing intermediate container 56 ---> 57Step 3/5 : WORKDIR /app/reactbeginnersguide 58 ---> Running in 59Removing intermediate container 0 60 ---> 61Step 4/5 : EXPOSE 8080 62 ---> Running in 63Removing intermediate container 64 ---> 65Step 5/5 : CMD nginx -g "daemon off;" 66 ---> Running in 67Removing intermediate container 68 ---> 69 70Successfully built 71Successfully tagged react_webserver:latest 72
shell
1 2$docker-compose up -d --build 3Creating network "react_default" with the default driver 4Building webserver 5Step 1/5 : FROM nginx:mainline-alpine 6 ---> 7Step 2/5 : RUN apk update; apk add nodejs npm; npm install -g browserify; npm install -g babel-cli; apk add git; 8 ---> Using cache 9 ---> 10Step 3/5 : WORKDIR /app/react 11 ---> Using cache 12 ---> 13Step 4/5 : EXPOSE 8080 14 ---> Using cache 15 ---> 16Step 5/5 : CMD nginx -g "daemon off;" 17 ---> Using cache 18 ---> 19 20Successfully built 21Successfully tagged react_webserver:latest 22Creating nginx ... done 23
shell
1 2$docker exec -it nginx /bin/sh 3/app # browserify --version 4/bin/sh: browserify: not found 5/app # babel --version 6/bin/sh: babel: not found 7

回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2019/08/28 13:29
2019/08/29 02:35