Search code examples
laraveldockerlaravel-sail

Laravel sail: login as root or create an root user


I am using sail and trying to use the shell as root, which is not possible. Switching to user root asks for a password, which is not know to me.

I tried to change the dockerfile:

ARG WWWROOTGROUP
RUN groupadd --force -g $WWWROOTGROUP sailRoot
RUN useradd -ms /bin/bash --no-user-group -g $WWWROOTGROUP -u 1337 sailRoot

RUN usermod -aG sudo sail
RUN usermod -aG sudo sailRoot

I tried to add a new user and give him and the standard sail user root privileges, but it doesnt work. The sailRoot user isn't available inside the container. Of course I rebuild the container with that dockerfile. The changed dockerfile gets executed correctly as far as I can tell.

Does anybody know how to change the user to root with sail?

What I want to do is to install imagemagick into the container. I already add "apt-get install imagemagick imagemagick-doc" to the dockerfile aswell, but its not installed inside the container. If you know how to do that, I would really appreaciate it!

Thanks.


Solution

  • Just use: sail root-shell

    Or an alias: sail root-bash

    For more information, you can type sail help (in recent editions of Laravel Sail) or review the source code.