无法创建 Dockerfile 映像 /bin/sh:apt-get:未找到
Failed to craeate Dockerfile image /bin/sh: apt-get: not found
嗨,我可以寻求一些帮助吗我正在构建图像 Dockerfile
但是我得到这个错误 /bin/sh: apt-get: not found
,我没有拉 O.S 因为我知道 docker 有一个默认值 O.S ?
Executing busybox-1.31.1-r9.trigger
OK: 12 MiB in 31 packages
Removing intermediate container 9a28ea5578ed
---> 73b493dcd606
Step 3/7 : RUN apt-get update && apt-get install –y nginx
---> Running in 9e2bb52cd7c8
/bin/sh: apt-get: not found
The command '/bin/sh -c apt-get update && apt-get install –y nginx' returned a non-zero code: 127
FROM php:7.4-fpm-alpine
#RUN docker-php-ext-install pdo
RUN docker-php-ext-install pdo_mysql
RUN apt-get update \
&& apt-get install –y nginx
COPY index.php /var/www/myapp
ADD default.conf /etc/nginx/conf.d/default.conf
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]
您的基本映像 php:7.4-fpm-alpine
的 Linux 分发包是 Alpine instead of Ubuntu, so you need to use apk
而不是 apt-get
作为包管理器。
RUN apk update && apk add nginx
因为您使用的是 alpine
基础图像而不是 ubuntu
。因此,alpine
的包管理器是 apk
而不是 apt
或 apt-get
命令应该是
RUN apk update && \
apk add --no-cache nginx
--no-cache
选项允许不在本地缓存索引,这对于保持容器较小很有用。
Ref:- https://www.cyberciti.biz/faq/10-alpine-linux-apk-command-examples/
嗨,我可以寻求一些帮助吗我正在构建图像 Dockerfile
但是我得到这个错误 /bin/sh: apt-get: not found
,我没有拉 O.S 因为我知道 docker 有一个默认值 O.S ?
Executing busybox-1.31.1-r9.trigger
OK: 12 MiB in 31 packages
Removing intermediate container 9a28ea5578ed
---> 73b493dcd606
Step 3/7 : RUN apt-get update && apt-get install –y nginx
---> Running in 9e2bb52cd7c8
/bin/sh: apt-get: not found
The command '/bin/sh -c apt-get update && apt-get install –y nginx' returned a non-zero code: 127
FROM php:7.4-fpm-alpine
#RUN docker-php-ext-install pdo
RUN docker-php-ext-install pdo_mysql
RUN apt-get update \
&& apt-get install –y nginx
COPY index.php /var/www/myapp
ADD default.conf /etc/nginx/conf.d/default.conf
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]
您的基本映像 php:7.4-fpm-alpine
的 Linux 分发包是 Alpine instead of Ubuntu, so you need to use apk
而不是 apt-get
作为包管理器。
RUN apk update && apk add nginx
因为您使用的是 alpine
基础图像而不是 ubuntu
。因此,alpine
的包管理器是 apk
而不是 apt
或 apt-get
命令应该是
RUN apk update && \
apk add --no-cache nginx
--no-cache
选项允许不在本地缓存索引,这对于保持容器较小很有用。
Ref:- https://www.cyberciti.biz/faq/10-alpine-linux-apk-command-examples/