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

SimonAngatia's avatar

Laravel sail stuck at building project stage on WSL2

I have a laravel project that I setup using Laravel sail. When I run the sail up -d command, it starts building the project but never finishes. It gets stuck at installing gnpu ... The following are the commandline logs at the point where it gets stuck. Someone help me solve this issue. I have tried researching everywhere but haven't found an answer.

 => [ 4/13] RUN apt-get update     && apt-get install -y gnupg gosu curl ca-certificates zip unzip git supervi  1513.6s
 => => # 0 added, 0 removed; done.
 => => # Running hooks in /etc/ca-certificates/update.d...
 => => # done.
 => => # Warning: apt-key output should not be parsed (stdout is not a terminal)
 => => # Executing: /tmp/apt-key-gpghome.6K2Sgv6ToW/gpg.1.sh --homedir /root/.gnupg --keyserver hkp://keyserver.ubuntu.
 => => # com:80 --recv-keys E5267A6C

My php 8.1 runtime Dockerfile:

FROM ubuntu:21.10

LABEL maintainer="Taylor Otwell"

ARG WWWGROUP
ARG NODE_VERSION=16
ARG POSTGRES_VERSION=14

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 sqlite3 libcap2-bin libpng-dev python2 \
    && mkdir -p ~/.gnupg \
    && chmod 600 ~/.gnupg \
    && echo "disable-ipv6" >> ~/.gnupg/dirmngr.conf \
    && apt-key adv --homedir ~/.gnupg --keyserver hkp://keyserver.ubuntu.com --recv-keys 0x14AA40EC0831756756D7F66C4F4EA0AAE5267A6C \
    && echo "deb https://ppa.launchpadcontent.net/ondrej/php/ubuntu impish 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-sqlite3 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('https://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 \
    && curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - \
    && echo "deb https://dl.yarnpkg.com/debian/ stable main" > /etc/apt/sources.list.d/yarn.list \
    && echo "deb http://apt.postgresql.org/pub/repos/apt impish-pgdg main" > /etc/apt/sources.list.d/pgdg.list \
    && curl --silent -o - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - \
    && apt-get update \
    && apt-get install -y yarn \
    && apt-get install -y mysql-client \
    && apt-get install -y postgresql-client-$POSTGRES_VERSION \
    && 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"]

My docker-compose.yml file:

version: '3'
services:
    laravel.test:
        build:
            context: ./docker/8.0
            dockerfile: Dockerfile
            args:
                WWWGROUP: '${WWWGROUP}'
        image: sail-8.0/app
        ports:
            - '${APP_PORT:-80}:80'
        environment:
            WWWUSER: '${WWWUSER}'
            LARAVEL_SAIL: 1
        volumes:
            - '.:/var/www/html'
        networks:
            - sail
        depends_on:
            # - mysql
            # - memsql
            - pgsql
            - redis
            # - selenium
    # selenium:
    #     image: 'selenium/standalone-chrome'
    #     volumes:
    #         - '/dev/shm:/dev/shm'
    #     networks:
    #         - sail
    mysql:
        image: 'mysql:8.0'
        ports:
            - '3305:3306'
        environment:
            MYSQL_ROOT_PASSWORD: '${DB_PASSWORD}'
            MYSQL_DATABASE: '${DB_DATABASE}'
            MYSQL_USER: '${DB_USERNAME}'
            MYSQL_PASSWORD: '${DB_PASSWORD}'
            MYSQL_ALLOW_EMPTY_PASSWORD: 'yes'
        volumes:
            - 'sailmysql:/var/lib/mysql'
        networks:
            - sail
        healthcheck:
          test: ["CMD", "mysqladmin", "ping"]
    pgsql:
        image: postgres:13
        ports:
            - '${FORWARD_DB_PORT:-5432}:5432'
        environment:
            PGPASSWORD: '${DB_PASSWORD:-secret}'
            POSTGRES_DB: '${DB_DATABASE}'
            POSTGRES_USER: '${DB_USERNAME}'
            POSTGRES_PASSWORD: '${DB_PASSWORD:-secret}'
        volumes:
            - 'sailpostgresql:/var/lib/postgresql/data'
        networks:
            - sail
        healthcheck:
          test: ["CMD", "pg_isready", "-q", "-d", "${DB_DATABASE}", "-U", "${DB_USERNAME}"]
#    memsql:
#        image: 'memsql/cluster-in-a-box'
#        ports:
#            - '3306:3306'
#            - '8080:8080'
#        environment:
#            LICENSE_KEY: '${MEMSQL_LICENCE}'
#            ROOT_PASSWORD: '${MEMSQL_ROOT_PWD}'
#        volumes:
#              - 'sailmemsql:/var/lib/memsql'
#        networks:
#              - sail
    redis:
        image: 'redis:alpine'
        ports:
            - '${FORWARD_REDIS_PORT:-6379}:6379'
        volumes:
            - 'sailredis:/data'
        networks:
            - sail
        healthcheck:
          test: ["CMD", "redis-cli", "ping"]
    # memcached:
    #     image: 'memcached:alpine'
    #     ports:
    #         - '11211:11211'
    #     networks:
    #         - sail
    mailhog:
        image: 'mailhog/mailhog:latest'
        ports:
            - '${FORWARD_MAILHOG_PORT:-1025}:1025'
            - '${FORWARD_MAILHOG_DASHBOARD_PORT:-8025}:8025'
        networks:
            - sail
networks:
    sail:
        driver: bridge
volumes:
    sailmysql:
        driver: local
    sailmemsql:
        driver: local
    sailpostgresql:
        driver: local
    sailredis:
        driver: local

The distro installed on the WSL2 is ubuntu.

0 likes
7 replies
LaryAI's avatar
Level 58

It looks like the issue is related to the gnupg package that is being installed. It appears that the gnupg package is not being installed correctly, which is causing the build to get stuck.

I would suggest trying to install the gnupg package manually using the following command:

sudo apt-get install gnupg

If that doesn't work, you could try removing the gnupg package and then reinstalling it using the following commands:

sudo apt-get remove gnupg
sudo apt-get install gnupg

If that still doesn't work, you could try updating the gnupg package using the following command:

sudo apt-get update gnupg

If none of these solutions work, you could try using a different version of the gnupg package. You can find the available versions of the gnupg package by running the following command:

apt-cache policy gnupg

Once you have found the version you want to use, you can install it using the following command:

sudo apt-get install gnupg=<version>

I hope this helps!

CamKem's avatar

Is there a specific reason you are using Sail? Personally I just use valet, it much much simpler as there is no virtualisation, you still get to use the .test custom local domain & it's so simple to set up & maintain - then with the PHPmon app it gives you a great UI in your menu bar to be able to monitor & edit the Valet config.

SimonAngatia's avatar

@CamKem I am on windows and I have just seen that vale is for Mac. Also, the project I am working on was initially set up with Laravel sail.

Please or to participate in this conversation.