无法创建Dockerfile映像/ bin / sh:apt-get:找不到

问题描述 投票:0回答:2

HI,我可以寻求帮助吗,我正在构建映像Dockerfile但是我收到此错误/bin/sh: apt-get: not found,我没有拉OS,因为我知道docker具有默认的OS?

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;"]
docker dockerfile docker-image
2个回答
1
投票

基本映像php:7.4-fpm-alpine的Linux发行版是Alpine而不是Ubuntu,因此您需要使用apk而不是apk作为程序包管理器。

apt-get

1
投票

由于正在使用RUN apk update && apk add nginx 基本图像,而不是alpine。因此,ubuntu的程序包管理器是alpine而不是apkapt

命令应该是

apt-get

Ref:-RUN apk update && \ apk add --no-cache nginx \

© www.soinside.com 2019 - 2024. All rights reserved.