i didn’t understand which parameters are user and uid, I tried to use my Macbook username and password, but said uid aren’t correct. So I don’t understant what parameters it’s asking me

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

×
1 answer

Hi there @lorenzobattelli,

Can you please give a little bit more information on which tutorial exactly are you following and what is the exact error that you are seeing?

Regards,
Bobby

  • Ops, apologies, I thought my comment would have been posted right on the bottom of the tutorial I was reading :).

    The tutorial I meant is at this link:
    https://www.digitalocean.com/community/tutorials/how-to-containerize-a-laravel-application-for-development-with-docker-compose-on-ubuntu-18-04

    and it’s about
    “How To Containerize a Laravel Application for Development with Docker Compose on Ubuntu 18.04”

    The parameters I was talking about are: “user”, and “uid”. Referenced at the
    “Step 3 — Setting Up the Application’s Dockerfile” of this article.
    There, it talks about creating a new system user, so I tried to initialize those args (user, uid) in the docker-compose.yml as they are my MacBook Pro accessing credentials. However, at the end of the guide, the command “docker-compose build app” return the following error message:

    “Step 8/11 : RUN useradd -G www-data,root -u $uid -d /home/$user $user
    —> Running in 90abae730aba
    useradd: invalid user ID ’<myMacBookPassword>’
    ERROR: Service ‘app’ failed to build: The command ’/bin/sh -c useradd -G www-data,root -u $uid -d /home/$user $user’ returned a non-zero code: 3”

    At this point I mightn’t have understood which value those args should assume.

    Thanks!! 🙏

    Lawrence

    by Erika Heidi
    In this guide, we'll use Docker Compose to containerize a Laravel application for development. When you're finished, you'll have a demo Laravel application running on three separate service containers.
    • Hi there @lorenzobattelli,

      The user and the uid arguments are taken from the docker-compose file:

      Docker Compose

      You should not change the values directly in your Dockerfile as they are passed over as an argument from docker-compose.

      Let me know how it goes!
      Regards,
      Bobby

      • Hi @bobbyiliev

        It seems I revolved this problem, I inserted user and uid properly I guess, and finally I could get to the final steps of the guide.

        The command docker-compose build app produced a success to me.

        But bad news are coming after that.
        after I run docker-compose up -d and then docker-compose exec app composer install there’s an error message, about dependency conflict with packages I guess


        Your requirements could not be resolved to an installable set of packages.

        Problem 1
        - facebook/webdriver 1.7.1 requires ext-zip * -> the requested PHP extension zip is missing from your system.
        - facebook/webdriver 1.7.1 requires ext-zip * -> the requested PHP extension zip is missing from your system.
        - Installation request for facebook/webdriver 1.7.1 -> satisfiable by facebook/webdriver[1.7.1].

        To enable extensions, verify that they are enabled in your .ini files:
        -
        - /usr/local/etc/php/conf.d/docker-php-ext-bcmath.ini
        - /usr/local/etc/php/conf.d/docker-php-ext-exif.ini
        - /usr/local/etc/php/conf.d/docker-php-ext-gd.ini
        - /usr/local/etc/php/conf.d/docker-php-ext-pcntl.ini
        - /usr/local/etc/php/conf.d/docker-php-ext-pdo_mysql.ini
        - /usr/local/etc/php/conf.d/docker-php-ext-sodium.ini
        You can also run php --ini inside terminal to see which files are used by PHP in CLI mode.


        however If I ignore this for a moment, I continue on with the tutorial, after the artisan key:generate, I try to visit http://localhost:8000 and a Laravel debug screen appears, with the following error: (I’m sorry I didn’t find out how to share the png into this chat)

        InvalidArgumentException thrown with message “View [auth.login] not found.”

        It seems it doesn’t see my application .blade.php files. but my app works. I mean, if I run my app in the classic mode, locally, by artisan serve, without dockerization, everything works fine. So maybe it’s a matter of wrong path somewhere? could it be? maybe /var/www we set in the docker compose file? ( Note that I’m working on MacBook with Catalina) or maybe the problem is the dependency problem above which causes a chain of further problems?

        (I really try to resolve these errors but I can’t realize why those happen, the configurations in the previous steps of the tutorial are correct, or at least, I think they are. I tried to follow all of the step as better as I could)

        I thank you for your help !!

        • Hi there @lorenzobattelli,

          Can you share your Dockerfile? Usually, if you use the FROM php:7.4-fpm base image you should not get those errors as the PHP extensions should already be in place.

          Regards,
          Bobby

          • Dear @bobbyiliev,

            i resolved the “Auth.login view not found ” by simply clearing cache, config etc, using commands php artisan clear:cache, view:clear etc.
            This trick is the first thing our University Professor taught us when developing with Laravel, and still the first thing I forgot to do. Damn :)
            The problem was the dirty cache which contained data from my host system ,which was inherited by the virtualization of the php image.

            about the dependency problem: I resolved it by running further commands into the container. I specified different versions of the dependency which should have worked for this particular php image, and then “composer install” finally worked, and conflicts was resolved.

            But this last issue was the lesser in importance.
            The first one I wrote about was the one that really blocked me.

            Now the app works fine. This tutorial was absolutely perfect, nothing to say.

            I share with you the Dockerfile, as you asked, nonetheless.

            FROM php:7.4-fpm
            ARG user
            ARG uid
            RUN apt-get update && apt-get install -y \
            git \
            curl \
            libpng-dev \
            libonig-dev \
            libxml2-dev \
            zip \
            unzip
            RUN apt-get clean && rm -rf /var/lib/apt/lists/*
            RUN docker-php-ext-install pdo_mysql mbstring exif pcntl bcmath gd
            COPY –from=composer:latest /usr/bin/composer /usr/bin/composer
            RUN useradd -G www-data,root -u $uid -d /home/$user $user
            RUN mkdir -p /home/$user/.composer && \
            chown -R $user:$user /home/$user
            WORKDIR /var/www
            USER $user

            PS; I thank you so much for your time, your availability, and your kindness.

            My best regards,

            Lorenzo Battelli

          • Dear @bobbyiliev,

            I’ve been trying to resolve another problem for 2 weeks. By taking this tutorial about “containerizing our Laravel application with docker-compose” as start point, I tried to deploy my new docker image (created with “docker-compose build app”, as we seen in the guide) to my DockerHub repository. In order to do this, I tried to run

            docker image push <repoName>:latest

            then it was successfully push to my repo.
            But here’s the problem, let’s assume I’m someone else, (a co-worker for example), and I want to pull this application that has been previously push to the repo with docker image push …, after the pulling I get an empty image, in particular if I run

            docker container run -it <pulled_Image_Name> bash

            and visit /var/www/ I notice that this directory doesn’t contain my Laravel application file, but only an empty directory called “html”. So this image is useless for everyone who want to pull my application. Maybe is that something wrong in Pushing process?

            Maybe is the dir /var/www empty because of some lack in the Dockerfile?

            Plan B, I tried to run the pulled image by using
            docker-compose up
            but obviously it says “docker compose file not found”.

            I really don’t understand how to deploy on DockerHub a multi-containerized Laravel application with docker-compose, in order to let other people pulling it and running it.

            Thank you very much,

            Lorenzo Battelli

Submit an Answer