Docker Community Forums

Share and learn in the Docker community.

Building image but raise an error /bin/sh: apt-get: not found

HI can I ask some help I’m building the image Dockerfile
but I get this error /bin/sh: apt-get: not found

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

Here is my Dockerfile

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

CMD ["nginx", "-g", "daemon off;"]

can you also please check my CMD if that is correct?

Thank you in advance

You are using an alpine based base image and expect it to have debian/ubuntu tools? That’s not going to work.

Alpine uses apk. Try apk add --no-cache nginx instead.

Thank you for helping me