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

dlopez079@gmail.com's avatar

Sail / Docker Nightmare

I am trying my absolute best to work with Laravel/Sail/Docker but it is just not working out for me. I have experienced more frustration than I have completed work. I have finally come across a hurdle that I just can't get by. I have to put this Laravel framework down for now and hope that my frustration can let me concentrate and get back into creating again.

For starters. I can only work on projects on my laptop. When I try to work with an existing project on my desktop (after creating and working on it with my laptop), I can never get it to work.

  1. I clone the project into Ubuntu 20 distro using WSL2.
  2. I use the following: docker run --rm -u "$(id -u):$(id -g)" -v $(pwd):/opt -w /opt laravelsail/php80-composer:latest composer install --ignore-platform-reqs
  3. I make sure my env file (from the laptop) is copied to the desktop.
  4. I run Sail up -D

Results: WARN[0000] The FORWARD_DB_PORT variable is not set. Defaulting to a blank string. WARN[0000] The FORWARD_REDIS_PORT variable is not set. Defaulting to a blank string. WARN[0000] The FORWARD_MEILISEARCH_PORT variable is not set. Defaulting to a blank string. WARN[0000] The FORWARD_MAILHOG_PORT variable is not set. Defaulting to a blank string. WARN[0000] The FORWARD_MAILHOG_DASHBOARD_PORT variable is not set. Defaulting to a blank string. WARN[0000] The FORWARD_DB_PORT variable is not set. Defaulting to a blank string. WARN[0000] The FORWARD_REDIS_PORT variable is not set. Defaulting to a blank string. WARN[0000] The FORWARD_MEILISEARCH_PORT variable is not set. Defaulting to a blank string. WARN[0000] The FORWARD_MAILHOG_PORT variable is not set. Defaulting to a blank string. WARN[0000] The FORWARD_MAILHOG_DASHBOARD_PORT variable is not set. Defaulting to a blank string. WARN[0000] The FORWARD_DB_PORT variable is not set. Defaulting to a blank string. WARN[0000] The FORWARD_REDIS_PORT variable is not set. Defaulting to a blank string. WARN[0000] The FORWARD_MEILISEARCH_PORT variable is not set. Defaulting to a blank string. WARN[0000] The FORWARD_MAILHOG_PORT variable is not set. Defaulting to a blank string. WARN[0000] The FORWARD_MAILHOG_DASHBOARD_PORT variable is not set. Defaulting to a blank string.

I HAVE TRIPPLE CHECKED AND THE PORTS ARE ON THE ENV FILE SO I DON'T UNDERSTAND WHY IM GETTING THIS MESSAGE!!!!!!!!

All ports are listed in the ENV file. ALL OF THEM.

I searched online and I don't find anything that helps resolve the issue. If I do find anything, it is not written clearly enough for me to understand it. I'm posting here because this is where I learn the most.

I need to understand why is it so difficult to work on one project on 2 different computers when it comes to Laravel / Sail / Docker?

FYI: Sail is not even a category to select from so I can post this. I wonder if this solution is even worth it.

0 likes
10 replies
bugsysha's avatar

I'm probably biased, but I don't think Windows is good for development. It is far better than before, but still far from the required stability. Or maybe it is due to beginners using Windows and lack of experience causes these issues.

But to answer your question, it is not hard. Never had an issue with my computers.

1 like
dlopez079@gmail.com's avatar

I shouldn't be hard.

I have everything set up correctly on my laptop. I can work fine from there. If I want to move my project to my desktop, it's not so cut and dry.

I use Github to save my work. I clone the GitHub repository and use composer to install my dependencies as per the Laravel sail documentation. I then run sail to create my containers.

I have 4 different projects and I'm getting the same results for all four.

Not only do I get the above error message. I also get an error message when I try to access the database. Access denied for user 'sail'@'172.21.0.1' (using password: YES)

Yes. I am new. But I do understand what is happening. Windows is using a virtual Linux Distro for development. From there, I am using docker containers for the services that my application requires. All of this is set up with the docker_composer file and the ./docker/8.0/Dockerfile.

What I don't understand is.......If I am pushing my project to Github. Why is it that that same project will not work on another computer once I clone it down?

Now. Let's say I run off and get a Mac computer, will I experience the same thing? I think I will experience the same exact thing on both OS.

There has to be something that I'm missing.

x7ryan's avatar

I'm probably biased too since I would never buy a Mac so the choice for me is Linux or Windows and Linux won't run everything I need and I am too lazy to dual boot, Either way though I find Windows works just fine. I think to say it is not stable enough as a development environment is probably a sign you haven't really tried using Windows seriously. Or at least not a version that wasn't Vista or 8 (because I agree those weren't that great).

bugsysha's avatar

Let's say I run off and get a Mac computer, will I experience the same thing?

@dlopez079 don't do that. Install Linux (Ubuntu) and see if you can replicate the issue. No need to waste money.

1 like
jlrdw's avatar

@dlopez079 just curious, have you considered developing on desktop without a container, or perhaps use homestead.

1 like
dlopez079@gmail.com's avatar

Yeah. I used Homestead (virtual box) previously. I didn't have a problem with that at all. I mean...I can just use that. I just hate that I can't understand why I am not able to make Sail work on multiple computers.

jlrdw's avatar

Just curious, have you looked at other alternatives, I use bitnami stacks, but there is also laragon. But just a thought, personally after looking over sail and docker, I will stay with bitnami. Similar to xampp, but I just like it better.

Again just a thought and curious question.

1 like
dlopez079@gmail.com's avatar

I'll give that a try and provide feed back. I like using anything new. I'm super open to trying something new.

Stetzone's avatar

I started having this issue with the FORWARD_DB_PORT and FORWARD_REDIS_PORT:

WARN[0000] The FORWARD_DB_PORT variable is not set. Defaulting to a blank string.
WARN[0000] The FORWARD_REDIS_PORT variable is not set. Defaulting to a blank string.

I updated my .env and added the following and I'm all good again:

FORWARD_DB_PORT="${DB_PORT}"
FORWARD_REDIS_PORT="${REDIS_PORT}"

I know OP said they made sure these variables are set in the .env, but maybe this will help others.

1 like
dlopez079@gmail.com's avatar
Level 4

I figured it out. The ENV file should be in the project before you run the docker run code. I added the env file after when I ran into this issue.

https://laravel.com/docs/8.x/sail#installing-composer-dependencies-for-existing-projects

	a. Clone Git Repository and add the ENV file before you run the below code.
	b. The following code is going to install application dependencies within the project folder (composer, php, and sail): 
		docker run --rm \
				-u "$(id -u):$(id -g)" \
				-v $(pwd):/var/www/html \
				-w /var/www/html \
				laravelsail/php80-composer:latest \
				composer install --ignore-platform-reqs
		> Confirm that sail, composer and npm is installed by checking their versions.
		> After you confirm that they are installed, run "sail up -d".
		> Once sail is up, run "apt update && apt upgrade" within sail shell-root to make sure you are working within the latest linux docker environment.
	c. Check the version of the composer app to make sure that it is the latest.
		> sail composer --version 
		> If it is not the latest version, update within sail shell-root using the "composer self-update" command.
	e. Check the version of NPM to make sure that it is the latest version
		> sail npm --version
		> If it is not the latest version, go into sail shell-root, type npm, and hit return.  The message response will tell you the code to download the latest npm version.  

Once you have this all checked, you can work. Let me know if I missed something or changed the wording of what I have provided. I'm still learning as I go and do not pretend to be a Laravel Sail Jedi.

1 like

Please or to participate in this conversation.