markshust / docker-magento

Mark Shust's Docker Configuration for Magento
https://m.academy/courses/set-up-magento-2-development-environment-docker/
MIT License
2.57k stars 1.01k forks source link

Improve/update Windows docker compose setup #100

Open birdman002 opened 6 years ago

birdman002 commented 6 years ago

I am on windows, I am working on going through this repo to install magento.

I get to the bin/copymagento, after it does all the pulls i get this error

cp: cannot stat '/src/.': No such file or directory

Not sure where I went wrong.

Thank you!

Best

markshust commented 6 years ago

sorry, i have windows versions but don't really support windows. you might want to ask your questino on stackoverflow.com.

my only guess is you are missing a directory named src.

birdman002 commented 6 years ago

I went through the steps, so just so i understand is that bin/copymagento is taking the magento source and copying it to the container? So would the src be missing on my computer or on the container?

Thanks for your help I appreciate you getting back to me

markshust commented 6 years ago

sounds like it would be missing on the host (your computer). so you probably need to unzip magento to your local src folder.

birdman002 commented 6 years ago

I unzipped it to my src folder.
docker-compose run -d --user=root --no-deps --rm -v $PWD/src/.:/source phpfpm cp -r /src/. /var/www/html

My error seems to be on the /src/ after the cp -r i believe. Should there also be the $PWD before as it is after the -v ? When i exec into the nginx container the app and bin folder are in the html folder. Should everything that is in the src folder on my host computer be in the html folder on the virtual box?

Thanks again, I appreciate it.

itsazzad commented 6 years ago

I am also facing the same issue: With PowerShell: cp: cannot stat '/src/.': No such file or directory With Git Bash: cp: cannot stat 'C:/Program Files/Git/src/': No such file or directory

markshust commented 6 years ago

I'm reopening this ticket (I actually don't know why I closed it in the first place). the windows configuration needs some updates, there have been a lot of updates to this repo and windows really wasn't factored in.

@zsoerenm did the initial windows config. not sure if you can help at all? 😋

zsoerenm commented 6 years ago

Yes in commit https://github.com/markoshust/docker-magento/commit/7bdd466f55b8573c336e40f2a30dc4ec8bcca1df#diff-9b7421fc1fe30ba6845586284d35a9fe source was falsely renamed to src Going to make a pull request.

zsoerenm commented 6 years ago

I wonder if the windows version is still functional. I had to copy the whole magento folder into the container because of permission problems when mounting the whole folder into the container. Instead I mounted only those folders into the container where the actual development happened (see https://github.com/markoshust/docker-magento/pull/83) so that the correct permissions could be set for the public folders. Unfortunately it was eventually reverted and now the whole folder gets mounted into the container: https://github.com/markoshust/docker-magento/commit/8af87f92eb68a11f82cc362061b397e2227d5a89#diff-4c1ddac5aca0fc7e08d5acd5c45a3c6b EDIT: It looks like Docker has changed the permission from 0755 to 0777 for shared volumes (see https://docs.docker.com/docker-for-windows/troubleshoot/#volumes). That means there is no need for Magento to be copied into the the container anymore. bin/copymagento can be removed and the current docker-compose.yml file is fine.

markshust commented 5 years ago

I merged this PR but this issue shouldn't have been closed.

Thank you @zsoerenm for the PR. The windows version definitely needs some work, so going to keep this ticket open to work on the windows docker compose setup. I don't have a Windows machine to test on, but would love to take a PR to fix it up so we can fully support it again.

markshust commented 5 years ago

i pinned this post on github to try to get it more attention.

zsoerenm commented 5 years ago

I am sorry that I did not have a look into this. In the mean time I started my own docker environment, since I wasn't happy with the multiple bash files, performance, etc. (BTW: I guess the performance of this environment got a lot better now) I also wanted to use docker in the production environment and to implement the recommended deployment strategy from Magento. Here you go: https://github.com/zsoerenm/magento2-docker There is still some documentation missing and I have to finalize the procedure going from development to production.

markshust commented 5 years ago

@zsoerenm cool, by the looks of it we came to the same resolution for performance :) yes very performant now.

i'm not super fond of how i implemented the bin helper scripts either, however i found it to be the best interim solution until we can figure out a better way so user's wouldn't need to understand all of the docker commands. i'll check out your repo for inspiration if i can for backporting windows support again. i also made a few steps towards making it compatible with unified dev/prod environments, needs a bit more work though. awesome job, i think we can all learn from each other.

alainseys commented 5 years ago

I am on windows, I am working on going through this repo to install magento. I get to the bin/copymagento, after it does all the pulls i get this error cp: cannot stat '/src/.': No such file or directory Not sure where I went wrong. Thank you! Best

did you create a enviroment variable for 7z ?

markojak commented 5 years ago

Hey @markshust, this is such an awesome repo and just missing Windows support (We have a few developers using Windows) and @zsoerenm seems to have done some great work here. Instead of us having so many forks of magento2-docker why don't you guys work together and make beautiful babies? ;)

markshust commented 5 years ago

@markojak really really appreciate your donation 👍 totally awesome

i would love to collab with @zsoerenm and try to get windows support back in here. i haven't taken a look at this issue in a while since the demand quite hasn't been there, and i'm working on some educational material right now that i believe is more important. that said, i would love a PR to get all of the scripts working for windows. fyi it was working at one time, the scripts are still up at https://github.com/markshust/docker-magento/tree/master/compose/magento-2-windows/bin -- i know @df2k2 is also a huge powershell guy so maybe he can chime in 😉

i'm so far disconnected from windows, i don't think i would be of much help here and i really don't want to go down that rabbit hole again unfortunately. but would love the current bin helper scripts at https://github.com/markshust/docker-magento/tree/master/compose/magento-2/bin backported to powershell. once they are fully backported i can most likely maintain all of it.

zsoerenm commented 5 years ago

I took a different approach: Shell scripts often depend on the operating system. That's why I reduced the number of scripts down to zero. IMHO, to get Magento up and running should be as easy as docker-compose up. This is even more pronounced if you use Docker for development and production. Nevertheless, @markshust has done a great job. I took some inspiration from here and the update rate is good. My repo needs some love. I won't have time to update it until next year.

markojak commented 5 years ago

@markshust - I've shared this repo with my colleagues as well and encouraged them to sponsor as well. I think for me the biggest challenge now isn't windows but rather the slow compile times. This is a function of the native filesharing volumes for MacOS + Docker - It seems that the only fix for this is docker-sync or something equivalent.

How do either of you deal with the slow speeds?

markshust commented 5 years ago

@markojak have you tried out this setup on a mac?

i blogged about docker performance for mac at https://markshust.com/2018/12/30/docker-mac-filesystem-volume-mount-approach-performance/ -- mainly comes down to using delegated volumes, and not syncing over entire folder structures. magento filesystem is the biggest baddest beast out there in php land, and pretty sure i hit every issue so far with it. that said, i use this setup daily and develop on it, and don't have any performance issues at all. docker-sync and the like are dead/deprecated in my head with the release of delegated volumes... i think the last time i used that was 3 years ago 😄

markshust commented 5 years ago

@zsoerenm i don't plan on getting rid of the helper scripts anytime soon, if anything i'll abstract them out even more. newbs don't know docker, nor should they need to know it. i'm trying to take more of a simpleton approach of abstracting docker away to the background. at the end of the day i don't want users to even know they are using docker.

df2k2 commented 5 years ago

thanks for the call out @markshust. I’d be happy to get involved here to see what o can do help. I have had a few ideas lately.

markojak commented 5 years ago

I checked out the blog post and I'm using your docker-dev.yml file as you've recommended in your course (great course by the way and thanks!)

Extract from my docker-dev file.

services:
  app:
    volumes:
      &appvolumes # Host mounts with performance penalty, only put what is necessary here
      - ./src/public/app/code:/var/www/html/app/code:delegated
      - ./src/public/app/design:/var/www/html/app/design:delegated
      - ./src/public/app/etc:/var/www/html/app/etc:delegated
      - ./src/public/composer.json:/var/www/html/composer.json:delegated
      - ./src/public/composer.lock:/var/www/html/composer.lock:delegated
      - ./src/public/nginx.conf:/var/www/html/nginx.conf:delegated
      #- ./src/var/log:/var/www/html/var/log:delegated
      #- ./src/var/report:/var/www/html/var/report:delegated
markojak commented 5 years ago

From my side I really like the helper scripts. I am quite familiar with docker commands but I also really like the bin scripts -- I have combined this with my own scripts to quickly run compile commands using things like mage2run

sunilit42 commented 4 years ago

any update for widnow ?

markshust commented 4 years ago

This is a final call for anyone wanting to contribute to Windows support for this repo. I have no desire to support Windows myself as I have no experience with it and don't see a real high demand for it. I'll be closing this ticket if someone doesn't want to take this by Dec 31, and will take Windows off the possible supported list of o/s's to support.

markshust commented 4 years ago

I'll be dropping the Windows-specific support because I've been told it works with WSL out of the box with no reported issues. The Windows-specific helper scripts take a ton of work to maintain, and it doesn't look like the demand is there especially with the improvement of WSL.

I'm going to test out WSL myself to ensure it works, and update the README to include any "gotcha" info to get things to work on Windows with WSL.

sunilit42 commented 4 years ago

Hello,

I try with winwow with WSL but when i run below command nothing happen curl -s https://raw.githubusercontent.com/markshust/docker-magento/master/lib/onelinesetup | bash -s -- magento2.test 2.3.3

alainseys commented 4 years ago

Hello,

I try with winwow with WSL but when i run below command nothing happen curl -s https://raw.githubusercontent.com/markshust/docker-magento/master/lib/onelinesetup | bash -s -- magento2.test 2.3.3

you do not have docker / docker-compose installed on wsl

alainseys commented 4 years ago

Hello,

I try with winwow with WSL but when i run below command nothing happen curl -s https://raw.githubusercontent.com/markshust/docker-magento/master/lib/onelinesetup | bash -s -- magento2.test 2.3.3

Bellow are the steps to get this working on WSL

sudo apt-get update -y sudo apt install docker.io

sudo /etc/init.d/docker start (no systemd) sudo apt-get install curl -y sudo curl -L "https://github.com/docker/compose/releases/download/1.24.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose sudo chmod +x /usr/local/bin/docker-compose

curl -s https://raw.githubusercontent.com/markshust/docker-magento/master/lib/onelinesetup | bash -s -- magento2.test 2.3.2

alainseys commented 4 years ago

Don't forget to expose your Docker daemon and ad it to the bash rc file you can check if docker is running correctly by executing Docker - - version if it shows up no errors than you are good to go.

sunilit42 commented 4 years ago

getting below error:- ERROR: Couldn't connect to Docker daemon at http+docker://localhost - is it running?

If it's at a non-standard location, specify the URL with the DOCKER_HOST environment variable.

alainseys commented 4 years ago

getting below error:- ERROR: Couldn't connect to Docker daemon at http+docker://localhost - is it running?

If it's at a non-standard location, specify the URL with the DOCKER_HOST environment variable.

first you need to expose the docker daemon on windows and then you need to export the variable:

export DOCKER_HOST=localhost:2375 echo "export DOCKER_HOST=localhost:2375" >> ~/.bash_profile echo "export DOCKER_HOST='tcp:0.0.0.0:2375'" ~/.bashrc

alainseys commented 4 years ago

you can test docker by docker-pull hello-world and docker run hello-world.

dont forget to install docker-compose

alainseys commented 4 years ago

Oh forgot to mention to to reload the bash file you need to run source ~/.bash_profile and source ~/.bashrc

sunilit42 commented 4 years ago

~/.bashrc /home/*/.bashrc: line 8: return: can only `return' from a function or sourced script

sunilit42 commented 4 years ago

Above issue fixed but docker info Cannot connect to the Docker daemon at tcp://localhost:2375. Is the docker daemon running?

alainseys commented 4 years ago

Above issue fixed but docker info Cannot connect to the Docker daemon at tcp://localhost:2375. Is the docker daemon running?

You have docker installed on your windows? Is the port exposed? Try connecting with vscode to wsl. You can also try and add tcp://0.0.0.0:2375 as well.

The docker status will keep reporting as not running since wsl canot check the status of a windows service.

You çan test if docker is working by docker-composé up or run hello-world.

sunilit42 commented 4 years ago

Hello,

i am working on window home edition so docker into window does not work

does possible to direct install into window ubnuntu and check it same like directly we do into linux

alainseys commented 4 years ago

Hello,

i am working on window home edition so docker into window does not work

does possible to direct install into window ubnuntu and check it same like directly we do into linux

Indeed hyper v does not work on home edition only on pro.

You çan indeed install virtual box and play with docker on vbox.

Or you can install Linux native

alainseys commented 4 years ago

i will give wsl 2 a try i will post the end result

alainseys commented 4 years ago

i have upgraded wsl to v 2 and the image builds as expected.

https://docs.microsoft.com/en-us/windows/wsl/wsl2-install

sunilit42 commented 4 years ago

Is that possible without docker in window?

alainseys commented 4 years ago

Is that possible without docker in window?

you can install docker without windows on linux or mac, if you want docker with integration on WSL you need to have docker on the host machine and inside the wsl instance

sunilit42 commented 4 years ago

is not possible just install docker into WSL and somehow allow tcp with the port with window machine without docker into the window.

markshust commented 4 years ago

FYI support for Windows-specific helper scripts has been dropped https://github.com/markshust/docker-magento/commit/b23f44ef97e6de9b6cfbc6ebe1f42e821bb87283

I'll keep this ticket open until Windows installation on WSL is documented.

alainseys commented 4 years ago

The steps that need to be followed are.

export DOCKER_HOST=localhost:2375 echo "export DOCKER_HOST=localhost:2375" >> ~/.bash_profile

echo "export DOCKER_HOST='tcp:0.0.0.0:2375'" ~/.bashrc

After this you should be able to run docker notice wsl can't give you the status of the docker service to check for errors run docker - - version if this does not result in a error your Docker instance is working.

And follow the Linux steps in this repo.

pparga commented 4 years ago

Hi @markshust ! Thanks for the nice repository that you have built! As you said creating the environment on wsl2 was pretty straight forward (same as linux), but I need some help connecting to the server via browser.

The problem seems to be from the wsl2 where, even though i added the entry on both host files (wsl2 and windows), i am unable to connect to it as the hosts seem to not be communicating. I have had these problems before with docker and wsl2, and the only workaround that actually worked for me is just accessing it via localhost and the port exposed in php for example. I couldn't do this now and i was wondering if you have any idea, suggestion, workaround that could help me.

Thanks again!

sunilit42 commented 4 years ago

Getting below error https://www.screencast.com/t/8fFjXw5Urqv

LiamKarlMitchell commented 4 years ago

Using WSL 2 with Ubuntu stuck at Extracting magento2-2.3.0.tar.gz to ./src Or maybe this just takes a very long time..., have you made published images that are ready to go?

This may help to speed up composer install.

composer global require hirak/prestissimo
willboudle commented 4 years ago

Does anyone have any good tutorials for getting M2 up and running on WSL 2? Eager to start this course and basically been unable to get a worth windows install for... ever.

LiamKarlMitchell commented 4 years ago

I haven't attempted it again yet, but have done some other projects that are not Magento 2. One note I have is if volume mapping the source folder don't do it from Windows the IO speed is still far too slow and it does not have inotify events.

Instead you can goto this in explorer can map it as a network drive and edit within it. \\wsl$\Ubuntu\root

Should only really have a volume for the app and a few other folders for persistence (media/static?) Vendor and lib folders can just be copied to the container.

When you open a Ubuntu terminal you can then do the docker-compose up and still have mounted volumes.

Maybe have the DB server just running on the host.