Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

kkpatel's avatar

Docker-laravel:Unable to locate package php8.1-cli

First Time Setting Up Docker with Sail

i run this command
 docker-compose up

The result of this command is:

 E: Unable to locate package php8.1-cli E: Couldn't find any package by
 E: Unable to locate package php8.1-cli E: Couldn't find any package by
 glob 'php8.1-cli' E: Couldn't find any package by regex 'php8.1-cli'
 E: Unable to locate package php8.1-dev E: Couldn't find any package by
 glob 'php8.1-dev' E: Couldn't find any package by regex 'php8.1-dev'
 E: Unable to locate package php8.1-pgsql ERROR: Service 'laravel'
 failed to build : Build failed

my docker file is

FROM ubuntu:21.04

LABEL maintainer="Taylor Otwell"

ARG WWWGROUP
ARG NODE_VERSION=16

WORKDIR /var/www/html

ENV DEBIAN_FRONTEND noninteractive
ENV TZ=UTC

RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone

RUN apt-get update \
    && apt-get install -y gnupg gosu curl ca-certificates zip unzip git supervisor libcap2-bin python2 \
    && mkdir -p ~/.gnupg \
    && chmod 600 ~/.gnupg \
    && echo "disable-ipv6" >> ~/.gnupg/dirmngr.conf \
    && apt-key adv --homedir ~/.gnupg --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys E5267A6C \
    && apt-key adv --homedir ~/.gnupg --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys C300EE8C \
    && echo "deb http://ppa.launchpad.net/ondrej/php/ubuntu hirsute main" > /etc/apt/sources.list.d/ppa_ondrej_php.list \
    && apt-get update \
    && apt-get install -y php8.1-cli php8.1-dev \
       php8.1-pgsql php8.1-gd \
       php8.1-curl \
       php8.1-imap php8.1-mysql php8.1-mbstring \
       php8.1-xml php8.1-zip php8.1-bcmath php8.1-soap \
       php8.1-intl php8.1-readline \
       php8.1-ldap \
       php8.1-msgpack php8.1-igbinary php8.1-redis php8.1-swoole \
       php8.1-memcached php8.1-pcov php8.1-xdebug \
    && php -r "readfile('http://getcomposer.org/installer');" | php -- --install-dir=/usr/bin/ --filename=composer \
    && curl -sL https://deb.nodesource.com/setup_$NODE_VERSION.x | bash - \
    && apt-get install -y nodejs \
    && npm install -g npm \
    # && apt-get update \
    && apt-get install -y mysql-client \
    && apt-get -y autoremove \
    && apt-get clean \
    && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

RUN setcap "cap_net_bind_service=+ep" /usr/bin/php8.1

RUN groupadd --force -g $WWWGROUP sail
RUN useradd -ms /bin/bash --no-user-group -g $WWWGROUP -u 1337 sail

COPY start-container /usr/local/bin/start-container
COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf
COPY php.ini /etc/php/8.1/cli/conf.d/99-sail.ini
RUN chmod +x /usr/local/bin/start-container

EXPOSE 8000

ENTRYPOINT ["start-container"]

I'd be grateful for any help regarding this, thanks.

0 likes
10 replies
Sinnbeck's avatar

@kkpatel ok they just looked a bit different.

Try removing local images to force sail to download the newest

docker rmi $(docker images -a -q)
1 like
Sinnbeck's avatar

@kkpatel ok. Did you try using sail instead of docker directly as shown in the docs? sail up

Sinnbeck's avatar

@kkpatel ok maybe say what you have tried instead of having me type out every idea I have, which you already tried

3 likes
Krystian Laubach's avatar

I have resolved the issue: went for a walk with the dog and came back with fresh mind :)

I can confirm that updating Laravel Sail to the newest version 1.13.7 fixed the issue. I've been still using Dockerfile that I've published to docker folder. So, now I have changed context in my docker-compose.yml to

context: ./vendor/laravel/sail/runtimes/8.1

and now all works fine. The app container has been successfully built!

To fix the issue:

  1. composer update laravel/sail update Sail to 1.13.7 (newest)
  2. Make sure your docker-compose.yml use the newest Dockerfile (from vendor/laravel/sail/runtimes or publish correct Dockerfile to docker folder)

Main differences in Dockerfile

FROM ubuntu:21.04 => FROM ubuntu:21.10
&& echo "deb http://ppa.launchpad.net/ondrej/php/ubuntu hirsute main" > /etc/apt/sources.list.d/ppa_ondrej_php.list \ =>

&& echo "deb http://ppa.launchpad.net/ondrej/php/ubuntu impish main" > /etc/apt/sources.list.d/ppa_ondrej_php.list \
3 likes
antja's avatar

Hi,

We have the exact same issue on one of our teammates computer. Unfortunately, it didn't get resolved by above solution.

It's 2016 macbook with macOS Big Sur v. 11.4, if it makes a difference. I reckon the ultimate purpose of docker is that the environment would NOT make a difference but here it obviously does.

1 like

Please or to participate in this conversation.