0

I have a laravel app.

I used laravel sail to generate the docker-compose.yml file. Sail also created a Dockerfile in ./vendor/laravel/sail/runtimes/8.0 I see this also in the .yml file.

When I run on my local maschine docker-compose up it will create an image and run a container. This container works fine.

Now I use docker-compose build to create an image which I want to share with a colleague. Docker will create the image successfully. I push it to HUB via Docker Desktop and my colleague can pull it.

But the pulled image does not work. When I observe the container through the CLI the app code is not even there. It looks like an empty image. Same also happens when I pull it on my local maschine.

Something gets messed up when I push the image to docker. Does anyone have an idea whats happening?

As per request here are the steps to reproduce:

Add laravel sail to an existing laravel project (You do not need the execute this if you create a new laravel project, which is laravel 8+):

composer require laravel/sail --dev

Then follow the laravel sail guide and call:

php artisan sail:install

The above call will generate a docker-compose.yml

Now you can run a container with docker-compose up.

This will create an image and run a container. If you want to push this image to the HUB, then the issues appear.

Here is my docker-compose.yml

version: '3'
services:
    laravel.app:
        build:
            context: ./vendor/laravel/sail/runtimes/8.0
            dockerfile: Dockerfile
            args:
                WWWGROUP: '${WWWGROUP}'
        image: dockeruser/feedback_app:1.5
        extra_hosts:
            - 'host.docker.internal:host-gateway'
        ports:
            - '${APP_PORT:-80}:80'
        environment:
            WWWUSER: '${WWWUSER}'
            LARAVEL_SAIL: 1
            XDEBUG_MODE: '${SAIL_XDEBUG_MODE:-off}'
            XDEBUG_CONFIG: '${SAIL_XDEBUG_CONFIG:-client_host=host.docker.internal}'
        volumes:
            - '.:/var/www/html'
        networks:
            - sail
networks:
    sail:
        driver: bridge
Roman
  • 3,563
  • 5
  • 48
  • 104
  • 1
    Can you edit the question to include a [mcve]? In particular, does the Dockerfile actually `COPY` code into the image? (I've seen a couple of recent Laravel SO questions that have an "image" which is basically the unmodified `php:fpm` image, and inject the code via a bind mount, so the image doesn't actually contain the application and can't usefully be pushed.) – David Maze Nov 05 '21 at 13:42
  • @DavidMaze Thanks for the reply. You already mention a possible issue. I will check this out. I also tried to add simple instructions on how to reproduce the issue. – Roman Nov 05 '21 at 14:47
  • In the `docker-compose.yml` file you show, try deleting the `volumes:`; those inject local files into the image, and you won't have them available remotely. Does the application still work? – David Maze Nov 05 '21 at 15:23

0 Answers0