docker-magento icon indicating copy to clipboard operation
docker-magento copied to clipboard

No such container path

Open ryanjavens opened this issue 8 years ago • 7 comments

Container: Magento-2 OS: Mac OS High Sierra Shell: zsh and bash

Running ./bin/start command with a fresh terminal instance is giving me issues with startup on occasion.

~/code/fundamentals-of-magento-dev> ./bin/start
Starting fundamentals-of-magento-dev_db_1 ... done
Starting fundamentals-of-magento-dev_phpfpm_1 ... done
Starting fundamentals-of-magento-dev_app_1    ... done
Initiating bi-directional sync between host & containers...
Error: No such container:path: magento-dev_phpfpm_1:/var/www/html/app
Error: No such container:path: magento-dev_phpfpm_1:/var/www/html/bin
Error: No such container:path: magento-dev_phpfpm_1:/var/www/html/dev
Error: No such container:path: magento-dev_phpfpm_1:/var/www/html/generated
Error: No such container:path: magento-dev_phpfpm_1:/var/www/html/lib
Error: No such container:path: magento-dev_phpfpm_1:/var/www/html/phpserver
Error: No such container:path: magento-dev_phpfpm_1:/var/www/html/pub
Error: No such container:path: magento-dev_phpfpm_1:/var/www/html/setup
Error: No such container:path: magento-dev_phpfpm_1:/var/www/html/update
Error: No such container:path: magento-dev_phpfpm_1:/var/www/html/var
Error: No such container:path: magento-dev_phpfpm_1:/var/www/html/vendor
All containers have started successfully.

It looks like grep isn't grabbing the full path of my docker containers. Instead of pulling fundamentals-of-magento-dev_phpfpm_1, it is starting at magento-dev_phpfpm_1. I'm not a grep ninja, but here's what I've done to the /bin/copydir/ script to fix it.

I've changed this line: docker cp $(docker-compose ps|grep phpfpm|awk '{print $1}'):/var/www/html/$1 src/ to: docker cp $(echo ${PWD##*/}_phpfpm_1|awk '{print $1}'):/var/www/html/$1 src/

This seems to fix the issue for each attempt when I open a fresh terminal window. I wonder if this is due to my long folder names? My solution makes a few assumptions:

  1. The container is using the default naming convention of CURRENT-DIRECTORY_container-name_#.
  2. The phpfpm container that I want is the ONLY phpfpm container running, therefore I can hardcode the number.

I feel that this is a hacky solution, but does anyone with more grep experience know a quick fix for this? If this works I'd be happy to create a PR or investigate further into grep. Probably wouldn't be a bad thing to learn 😄

ryanjavens avatar Nov 01 '18 19:11 ryanjavens

what does docker ps show? looks like your containers aren't running. did you try running bin/start again after the above error?

markshust avatar Nov 01 '18 20:11 markshust

@markoshust

docker ps:

~/code/fundamentals-of-magento-dev> docker ps                               130
CONTAINER ID        IMAGE                              COMMAND                  CREATED             STATUS              PORTS                                                 NAMES
3fe8981462ae        markoshust/magento-nginx:1.13-6    "nginx -g 'daemon of…"   8 days ago          Up 27 seconds       80/tcp, 0.0.0.0:80->8000/tcp, 0.0.0.0:443->8443/tcp   fundamentals-of-magento-dev_app_1
e93ee89c8047        markoshust/magento-php:7.1-fpm-9   "docker-php-entrypoi…"   8 days ago          Up 27 seconds       9000-9001/tcp                                         fundamentals-of-magento-dev_phpfpm_1
a5c3e975d851        percona:5.7                        "docker-entrypoint.s…"   8 days ago          Up 28 seconds       0.0.0.0:3306->3306/tcp                                fundamentals-of-magento-dev_db_1

The containers are running, it just has the name fundamentals-of-magento-dev_phpfpm_1 instead of magento-dev_phpfpm_1.

This error is occurring when I first run ./bin/start and continues if I run ./bin/start or ./bin/restart after seeing these.

ryanjavens avatar Nov 02 '18 12:11 ryanjavens

sorry for the delay on this. did you happen to change the folder name after running your first bin/start?

i'm going to close this as unable to replicate. if you can supply exact steps to replicate this issue, i'll take another look. everything is working great for me on mac for new installs following the readme.

markshust avatar Nov 27 '18 17:11 markshust

@markoshust no worries! I'll double check and see if I can replicate it again. Will let you know of the steps if I'm able to see the same issue.

ryanjavens avatar Nov 27 '18 19:11 ryanjavens

@markshust I was able to replicate this by running echo $(docker-compose ps|grep phpfpm|awk '{print $1}') in a half screen width terminal. The string that is echoed back is truncated. If I run the same in full screen width terminal... it echos fine... whole thing is there. (to be clear... related to input parsing, not output display)

I only discovered this because my set up runs were failing and the container name looked wrong... then I found this report. Thanks @ryanjavens ! Maybe you can replicate on your Mac?

michael-pure avatar Apr 12 '19 03:04 michael-pure

I know issue is closed, but maybe this helps.

Whatever that is your path, it most likely contains newline character.

Try run this on your path: $(printf $your_path | tr -d ‘\r’) or $(printf $your_path | tr -d ‘\n’)

tomasinchoo avatar May 25 '19 19:05 tomasinchoo

It turns out this was exactly the case when I was listing files with find.

@tomasinchoo, thanks for nothing your solution down here, it helped!

kocielnik avatar Mar 17 '21 07:03 kocielnik