New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Running docker-compose exec workspace bash command on Windows env shows an error #563

Closed
kvahuja opened this Issue Jan 20, 2017 · 18 comments

Comments

Projects
None yet
8 participants
@kvahuja
Copy link
Contributor

kvahuja commented Jan 20, 2017

My workspace:

  • Windows 10
  • Docker version: 1.13.0 (9795)
  • Channel: Stable

after I am done with docker-compose up command i fire the following command to get to my shell..

docker-compose exec workspace bash

Then the command finishes, I am logged into the Shell but i get the following error as well...

bash: $'\r': command not found
bash: $'\r': command not found
bash: $'\r': command not found
bash: $'\r': command not found
bash: $'\r': command not found
bash: $'\r': command not found
bash: $'\r': command not found
bash: $'\r': command not found
bash: $'\r': command not found
bash: $'\r': command not found
bash: $'\r': command not found
bash: /home/laradock/aliases.sh: line 61: syntax error near unexpected token `$'{\r''
'ash: /home/laradock/aliases.sh: line 61: `function mkd() {

p.s.: I will try to fix the shell via PR, but want to record it.

@philtrep philtrep added the Type: Bug label Jan 20, 2017

@philtrep

This comment has been minimized.

Copy link
Member

philtrep commented Jan 20, 2017

@mikeerickson I believe that's from #557

@azamatsulaiman

This comment has been minimized.

Copy link

azamatsulaiman commented Jan 21, 2017

same error for me

@bagart

This comment has been minimized.

Copy link
Contributor

bagart commented Jan 31, 2017

is not 'just same'

/home/laradock/aliases.sh: line 2: $'\r': command not found

FIX:

sed -i 's/\r//' /home/laradock/aliases.sh
function mkd() {
    mkdir -p "$@" && cd "$@"
}

sh not work with func!

FIX:

sed -i 's/^#! \/bin\/sh/#! \/bin\/bash/' /home/laradock/aliases.sh

philtrep added a commit that referenced this issue Feb 5, 2017

Issues 563 (#580)
* #563
hotfix

* #563
\r

* #563
\r
@philtrep

This comment has been minimized.

Copy link
Member

philtrep commented Feb 5, 2017

Fixed by PR #580

@philtrep philtrep closed this Feb 5, 2017

@kvahuja

This comment has been minimized.

Copy link
Contributor

kvahuja commented Feb 6, 2017

does this require a full rebuild of all containers? (i would presume yes).

@bagart

This comment has been minimized.

Copy link
Contributor

bagart commented Feb 6, 2017

Yes. Need rebuild workspace image for copy
/home/laradock/aliases.sh

Or just run 2 sed command ^^^

@kvahuja

This comment has been minimized.

Copy link
Contributor

kvahuja commented Feb 6, 2017

i just rebuilt the workspace container and the error still comes when i login with root or laradock.

am i doing something wrong?

@bagart

This comment has been minimized.

Copy link
Contributor

bagart commented Feb 6, 2017

What about error message? :)))

@kvahuja

This comment has been minimized.

Copy link
Contributor

kvahuja commented Feb 6, 2017

the error message still pops up for both root and laradock users, exactly as it was before.

@bagart

This comment has been minimized.

Copy link
Contributor

bagart commented Feb 6, 2017

docker-compose stop
git pull
docker-compose build --pull workspace 

also, you can rebuild other docker container

@mikeerickson mikeerickson self-assigned this Feb 7, 2017

@kvahuja

This comment has been minimized.

Copy link
Contributor

kvahuja commented Feb 13, 2017

I went ahead and tested this on Linux (Ubuntu 14.04 to be precise) and it works fine. the problem I had was on Docker for Windows and the problem on Windows still exists.

from my original post here are the environment details:

My workspace:

Windows 10
Docker version: 1.13.0 (9795)
Channel: Stable

@bagart - I would like to reopen this, but i will let you be decide that one.

@bagart

This comment has been minimized.

Copy link
Contributor

bagart commented Feb 13, 2017

docker-compose build --pull workspace 

sorry. this is not force rebuild (if image is not updated)
for check create any file in /home/laradock

touch /home/laradock/123

try to delete and rebuild

docker-compose stop workspace 
docker-compose rm workspace 
docker-compose up -d workspace 

or delete it with Kitematic (Alpha)
image

check test file for exists

ls /home/laradock/123

must be error: path not found

and 1 more thing:

bash: $'\r': command not found

I not sure about file of script with that error.

try to run inside workspace container with laradock user:

/home/laradock/aliases.sh

if you get error like

bash: $'\r': command not found

problem in THIS file

and try dirty fix:

sed -i 's/\r//' /home/laradock/aliases.sh
sed -i 's/^#! \/bin\/sh/#! \/bin\/bash/' /home/laradock/aliases.sh

and repeat check

/home/laradock/aliases.sh

if you not have error anymore - problem is same

also, you can reed log with kitematic or

docker logs laradock_workspace_1
@kvahuja

This comment has been minimized.

Copy link
Contributor

kvahuja commented Feb 13, 2017

thanks for the pointer on SED.

Old Section for alias.sh

#####################################
# User Aliases
#####################################

USER laradock
COPY ./aliases.sh /home/laradock/aliases.sh
RUN echo "" >> ~/.bashrc && \
    echo "# Load Custom Aliases" >> ~/.bashrc && \
    echo "source /home/laradock/aliases.sh" >> ~/.bashrc && \
    echo "" >> ~/.bashrc 
 
USER root
RUN echo "" >> ~/.bashrc && \
    echo "# Load Custom Aliases" >> ~/.bashrc && \
    echo "source /home/laradock/aliases.sh" >> ~/.bashrc && \
    echo "" >> ~/.bashrc

replaced with following by adding the SED commands and my problem went away. not sure if you classify this as a bug in the Dockerfile.

P.S.: I haven't tested this on Ubuntu or other Linux environment (i don't have one).

#####################################
# User Aliases
#####################################

USER laradock
COPY ./aliases.sh /home/laradock/aliases.sh
RUN echo "" >> ~/.bashrc && \
    echo "# Load Custom Aliases" >> ~/.bashrc && \
    echo "source /home/laradock/aliases.sh" >> ~/.bashrc && \
    echo "" >> ~/.bashrc && \
    sed -i 's/\r//' /home/laradock/aliases.sh && \
    sed -i 's/^#! \/bin\/sh/#! \/bin\/bash/' /home/laradock/aliases.sh
    
USER root
RUN echo "" >> ~/.bashrc && \
    echo "# Load Custom Aliases" >> ~/.bashrc && \
    echo "source /home/laradock/aliases.sh" >> ~/.bashrc && \
    echo "" >> ~/.bashrc && \
    sed -i 's/\r//' /home/laradock/aliases.sh && \
    sed -i 's/^#! \/bin\/sh/#! \/bin\/bash/' /home/laradock/aliases.sh
@NisalG

This comment has been minimized.

Copy link

NisalG commented Mar 19, 2017

This is what worked for me:
Replace laradock/workspace/Dockerfile > 'User Alias' section according to @kvahuja

Rebuilt according to @bagart:
$ docker-compose stop
$ git pull
$ docker-compose build --pull workspace
$ docker-compose up -d nginx mysql
$ docker-compose exec workspace bash

@bagart

This comment has been minimized.

Copy link
Contributor

bagart commented Mar 20, 2017

yes - that command rebuild new workspace image
but not clear(rebuild) docker image workspace
how make it? my last comment about it

@MeiRct

This comment has been minimized.

Copy link

MeiRct commented May 23, 2017

@philtrep Wouldn't it be better to add the "sed" command which removes the \r instances to the workspace/Dockerfile-* files? (Dockerfile-56, Dockerfile-70, Dockerfile-71)
It can be added right after the creation of aliases.sh

@bagart

This comment has been minimized.

Copy link
Contributor

bagart commented May 23, 2017

for correct use without "\r" you need configure git on windows(or make correct choice on installation step)
"\r" must not present in git repo
PS: my fixes not for actual laradock version

Obscuresounds pushed a commit to Obscuresounds/laradock that referenced this issue May 27, 2017

@rogerroelofs

This comment has been minimized.

Copy link

rogerroelofs commented Jun 20, 2017

Since rebuilding my workspace image recently I'm not getting carriage returns at the end of output. I'm not sure if it is related to this change or not. My output looks like this now. I can make a separate issue if it turns out to be not related. I"m on a mac with the most recently pulled laradock master.

root@8e12e1ec8d42:/var/www# echo "hi"
                                     hi
                                       root@8e12e1ec8d42:/var/www# exit

agebeyaw pushed a commit to agebeyaw/laradock that referenced this issue Aug 22, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment