Ubuntu dockerfile cant install php-fpm

My code:
FROM ubuntu:latest
RUN apt-get upgrade -y && apt update -y
RUN apt-get install nginx -y
RUN apt-get install php-fpm -y

php-fpm gets hung up on asking for region and city, is there a way to install without the region and city prompts?

Solution is to use:

ARG DEBIAN_FRONTEND=noninteractive

Question is how do you plan to run nginx and php-fpm in one container? It is possible but I can’t see the solution in your code.

What I would not do is run apt-get upgrade in a container either. There are different opinions about it because upgrading packages could get you the latest packages with security fixes but unless you have your own security check, you can introduce new security holes too. The other problem is that you can increase the size of your images since you will have the older packages on one of the parent layers and the new versions on the new layer you create with that upgrade line.

Even if you use apt-get upgrade, you should do it after and not before apt-get update since the base image probably will not contain the APT cache so apt upgrade will not find any new version.

What you should NEVER do is use the “latest” tag in the FROM instruction. You will be surprised when the new Ubuntu release come out which doesn’t support what you do in the Dockerfile but you don’t remember exactly which ubuntu version you have started with so you can’t even fix your tag easily.

This is how I would do it:

FROM ubuntu:22.04
ARG DEBIAN_FRONTEND=noninteractive
RUN apt update -y \
  && apt-get install -y --no-install-recommends \
       nginx \