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

Alejo's avatar
Level 1

No application encryption key has been specified.

Hi all, I am having problems configuring my laravel 10 plus docker application, right now when I try to access localhost:9090 I get the error:

No application encryption key has been specified

I share with you the configuration files in case you can help me, thanks in advance

.env

APP_NAME=administrative-management-email-integration-api-with-php
APP_ENV=local
APP_KEY=base64:SM8OOrDyemHGO0qZznVesr6JyEoFwD2fwK7actoS+/M=
APP_PORT=9090
APP_ECHO_PORT=6001
APP_DEBUG=true
APP_URL=http://localhost:${APP_PORT}
APP_NETWORK=${APP_NAME}-aiudo

php.dockerfile

FROM php:8.1-fpm

# Arguments defined in docker-compose.yml
ARG user
ARG uid

# Install dependencies
RUN apt-get update && apt-get install -qy git curl zip libmcrypt-dev unzip libfreetype6-dev libjpeg62-turbo-dev libpng-dev libzip-dev zlib1g-dev

# Configure and install extensions
RUN docker-php-ext-configure gd --with-freetype --with-jpeg
RUN docker-php-ext-configure pcntl --enable-pcntl
RUN docker-php-ext-install -j$(nproc) pdo_mysql sockets gd pcntl exif ctype bcmath zip
RUN docker-php-ext-enable zip

# Install Redis extension
RUN pecl install redis \
    && docker-php-ext-enable redis

# Activate shell
RUN rm /bin/sh && ln -s /bin/bash /bin/sh

# Clear cache
RUN apt-get clean && rm -rf /var/lib/apt/lists/*

# Get latest Composer
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer

# Create system user to run Composer and Artisan Commands
RUN useradd -G www-data,root -u $uid -d /home/$user $user
RUN mkdir -p /home/$user/.composer && \
    chown -R $user:$user /home/$user

RUN chown -R $user:$user /var/www

# Set working directory \
WORKDIR /var/www

composer.json

"require": {
        "php": "^8.1",
        "guzzlehttp/guzzle": "^7.2",
        "laravel/framework": "^10.10",
        "laravel/sanctum": "^3.3",
        "laravel/tinker": "^2.8"
    },
0 likes
6 replies
Nakov's avatar

I would guess that it might be the config cached before you generated the app key, so maybe add this to your docker file:

RUN php artisan config:cache \
    && php artisan view:cache && php artisan view:clear

which will clear the cache when you build.

Alejo's avatar
Level 1

Hi @Nakov I'm going to try it but the order doesn't matter? or I add it before

Activate shell

RUN rm /bin/sh && ln -s /bin/bash /bin/sh

cheers

Nakov's avatar

@Alejo the order does matter, you have to be in the correct directory. Based on your dockerfile I would assume that the project is in the /var/www folder, so add that line at the very bottom, after:

# Set working directory \
WORKDIR /var/www
Alejo's avatar
Level 1

@Nakov Okay I did it but it didn't work :S I got an error:

=> ERROR [php stage-0 15/15] RUN php artisan config:cache && php artisan view:cache && php artisan view:clear 0.3s
------                                                                                                                                                                                                             
 > RUN php artisan config:cache && php artisan view:cache && php artisan view:clear:
0.257 No se pudo abrir el archivo de entrada: artisan
------
failed to solve: process "/bin/sh -c php artisan config:cache && php artisan view:cache && php artisan view:clear" did not complete successfully: exit code: 1
make: *** [Makefile:15: up] Error 17

Nakov's avatar

@Alejo I don't know in which directory you have your project in docker, so make sure you are within that directory first and then RUN the commands.

Alejo's avatar
Level 1

@Nakov Solved it, I started again using laravel version 9 and it's working fine🙂

Please or to participate in this conversation.