jemz
jemz

Reputation: 5153

ERROR: Service 'ubuntu' failed to build: The command '/bin/sh -c apt-get update

when I execute the command docker-compose up --build -d

I get these errors:

E: Unable to locate package php7.4 E: Couldn't find any package by glob 'php7.4' E: Couldn't find any package by regex 'php7.4' E: Unable to locate package php7.4-fpm E: Couldn't find any package by glob 'php7.4-fpm' E: Couldn't find any package by regex 'php7.4-fpm' ERROR: Service 'ubuntu' failed to build: The command '/bin/sh -c apt-get update && apt-get install -y curl zip unzip php7.4 php7.4-fpm gettext-base sudo' returned a non-zero code: 100

can you help me please what is wrong with my dockerfile and docker-compose.yml?

here is my dockerfile

FROM  ubuntu:18.04

# ENV PORT=80
# ENV FPMSTREAM=9000

RUN apt-get update \
    && apt-get install -y curl zip unzip \
            php7.4 php7.4-fpm \
            gettext-base sudo



COPY ./webapp /var/www/webapp

WORKDIR /var/www/webapp

ADD default.conf /etc/nginx/conf.d/default.conf

RUN chown -R www-data:www-data /var/www && \
  chmod -R 775 /var/www && \
  useradd -m docker && echo "docker:docker" | chpasswd && \
  adduser docker sudo

USER docker

docker-compose.yml

version: "3.8"
services:

  ubuntu:
    build: .
    container_name: ubuntu-container
    external_links:
      - nginx
      - db

  nginx:
    image: nginx:stable
    container_name: nginx-container
    ports:
      - "80:80"
    expose:
      - 9000
    volumes:
      - ./code:/var/www/webapp
      - ./default.conf:/etc/nginx/conf.d/default.conf

  db:
    image: mysql:8.0
    container_name: mysql-container
    command: --default-authentication-plugin=mysql_native_password
    restart: always
    env_file:
      - .env
    volumes:
      - ./mysql-data:/var/lib/mysql
    expose:
      - 3306
    ports:
      - "3306:3306"

Upvotes: 1

Views: 3142

Answers (2)

user4093955
user4093955

Reputation:

your problem is that you're trying to install a version of PHP which is not available in Ubuntu 18.04.

The latest available version is 7.2, so you need to replace php7.4 php7.4-fpm with either php php-fpm or php7.2 php7.2-fpm

Upvotes: 1

nischay goyal
nischay goyal

Reputation: 3480

Please try the below Dockerfile for build

FROM  ubuntu:18.04

# ENV PORT=80
# ENV FPMSTREAM=9000

#Add Repos for PHP modules
RUN apt-get update \
    && apt -y install software-properties-common \
    && add-apt-repository ppa:ondrej/php 

RUN apt-get update \
    && apt-get install -y curl zip unzip \
            php7.4 php7.4-fpm \
            gettext-base sudo



COPY ./webapp /var/www/webapp

WORKDIR /var/www/webapp

ADD default.conf /etc/nginx/conf.d/default.conf

RUN chown -R www-data:www-data /var/www && \
  chmod -R 775 /var/www && \
  useradd -m docker && echo "docker:docker" | chpasswd && \
  adduser docker sudo

USER docker

Upvotes: 0

Related Questions