I was trying to create a new laravel app with laravel sail and I ran the following command on ubuntu 20.0.4:
curl -s https://laravel.build/example-app | bash
But I got the following message:
docker: invalid reference format: repository name must be lowercase.
See 'docker run --help'.
bash: line 16: cd: example-app: No such file or directory
Get started with: cd example-app && ./vendor/bin/sail up
Here is a screen shot
(No folder is created)
You are using a directory with capitals and spaces, i.e: Sennay Files. Use a different directory or rename it to: Sennay_Files.
You are working on the Windows file system from within WSL (i.e. /mnt/c). This will cause a significant performance hit, and issues like the one you are experiancing, consider using the WSL file system. You can change to the WSL file system by typing
cd ~
Related
I am new to bash and trying to run the following script on Git Bash for Windows, on Windows Server 2022:
"C:\Program Files\Git\bin\bash.exe" -c C:/Users/agentSvc/AppData/Roaming/Composer/vendor/debricked/cli && php bin\console debricked:scan '' 123 gitHubOrg/repoName 456 https://github.com/repo local
I have falsified some of the values.
The documentation is here:- https://debricked.com/docs/integrations/cli.html
However, I get errors such as "Is a directory", etc. What is the correct syntax here? I am trying to change directory as per the documentation and then run the command.
I am trying to open a file inside docker bash (I am using ubuntu terminal btw) using the ff commands:
sudo docker container exec -it rubybox bash
mkdir rubyfiles
cd rubyfiles
touch Dockerfile
And now when I run:
code .
It's suppose to open the file in Visual Studio code but instead I got this error:
bash: code: command not found
Any idea what's the correct command or how to configure this in order to open a file inside docker or terminal after running code .?
You cannot open a GUI app with Docker. You need to share your screen with it.
See: https://medium.com/#SaravSun/running-gui-applications-inside-docker-containers-83d65c0db110
What you could do is to share the local PWD with Docker and work from here:
docker run -d -v $PWD:/t -w /t rubybox
I have bash script that performing some Docker commands:
#!/usr/bin/env bash
echo "Create and start database"
cd ../../database
cp -R ../../../scripts/db db/
docker build -t a_database:1 .
docker run --rm --name a_db -e POSTGRES_PASSWORD=docker -d -p 5432:5432 a_database:1
docker network connect --ip 172.23.0.5 a_network a_db
sleep 15
echo "Initialize database"
docker exec a_db /root/db/dev/init_db.sh
echo "Cleanup"
rm -rf db
On mac everything works fine, problem occurs when I try to start this script on windows machine. When I'm running it I receive an error:
OCI runtime exec failed: exec failed: container_linux.go:344: starting container process caused "exec: \"C:/Program Files/Git/root/db/dev/init_db.sh\": stat C:/Program Files/Git/root/db/dev/init_db.sh: no such file or directory": unknown
Directory and script (/root/db/dev/init_db.sh) exist inside docker container. I don't know why it tries to find script on host machine? Also when I perform command:
docker exec a_db /root/db/dev/init_db.sh
directly in command line (on windows) script is executed. Any idea what is wrong and why it's trying to use git ?
I had a similar problem... absolute paths with windows variables fixed mine:
$HOME/docker/...
Thanks to igaul answer I was able to run this on windows machine. There were two problems:
Path to script in docker container. Instead of:
docker exec a_db /root/db/dev/init_db.sh
should be:
docker exec a_db root/db/dev/init_db.sh
Line endings in init_db.sh. On windows machine after pulling repository from bitbucket line ending of init_db.sh was setup to CRLF what caused problem. I've added .gitattribute file to my repo and now init_db.sh file always has LF endings.
It's not a bug in Docker, but the way mingw handles these paths. Here is some more information about that "feature"; http://www.mingw.org/wiki/Posix_path_conversion. Prefixing the path with a double slash (//bin/bash) should prevent this, or you can set MSYS_NO_PATHCONV=1, see How to stop MinGW and MSYS from mangling path names given at the command line
I know questions with such an error have already been asked several times, however I couldn't find a solution so I'm assuming that my case is different.
I have a Dockerfile like this:
FROM alpine:latest as builder
RUN apk add --no-cache bash
COPY bin /main/bin
COPY conf /main/conf
RUN ./main/bin/my-script 1
FROM mysql:5.7
COPY --from=builder /main/dist/sql /sql
ADD generate-databases.sh /docker-entrypoint-initdb.d
and this is working absolutely fine both on Linux, and on macOS(using Docker Desktop).
The problem is that on Windows using Docker Desktop I get the following error:
Service 'db' failed to build: The command '/bin/sh -c ./main/bin/my-script 1' returned a non-zero code: 127
why does this happen only on Windows, while working fine in other platforms?
The problem was actually not strictly related with Docker but with the line-ending format of my bash scripts, which on Windows were CRLF by default while they should have been LF.
To solve the issue I forced LF format in my .gitattributes.
I have following Dockerfile:
FROM ubuntu:16.04
ARG path1=def_path1
RUN mkdir ${path1}
When I build this Dockerfile using following command:
docker build --build-arg path1=/home/dragan -t build_arg_ex .
I get following error when I execute it in MINGW bash on Windows 10:
$ ./build.sh --no-cache
Sending build context to Docker daemon 6.144kB
Step 1/3 : FROM ubuntu:16.04
---> 2a4cca5ac898
Step 2/3 : ARG path1=def_path1
---> Running in a35241ebdef3
Removing intermediate container a35241ebdef3
---> 01475e50af4c
Step 3/3 : RUN mkdir ${path1}
---> Running in 2759e683cbb1
mkdir: cannot create directory 'C:/Program': No such file or directory
mkdir: cannot create directory 'Files/Git/home/dragan': No such file or
directory
The command '/bin/sh -c mkdir ${path1}' returned a non-zero code: 1
Building same Dockerfile in Windows Command Prompt or on Linux or Mac is ok. The problem is only in MINGW bash terminal on Windows because it adds 'C:/Program Files/Git' before the path that is passed as argument.
Is there a way to execute this in MINGW bash so it does not add the 'C:/Program Files/Git' prefix?
Thanks
This is actually a bug/limitation of Git for Windows as described in the Release Notes under Known issues:
If you specify command-line options starting with a slash, POSIX-to-Windows path conversion will kick in converting e.g. "/usr/bin/bash.exe" to "C:\Program Files\Git\usr\bin\bash.exe". When that is not desired -- e.g. "--upload-pack=/opt/git/bin/git-upload-pack" or "-L/regex/" -- you need to set the environment variable MSYS_NO_PATHCONV temporarily, like so:
MSYS_NO_PATHCONV=1 git blame -L/pathconv/ msys2_path_conv.cc
Alternatively, you can double the first slash to avoid POSIX-to-Windows path conversion, e.g. "//usr/bin/bash.exe".
Further to #mat007's answer:
This bash function solved the problem more permanently for docker, without enabling MSYS_NO_PATHCONV globally, which causes another world of pain.
.bashrc
# See https://github.com/docker/toolbox/issues/673#issuecomment-355275054
# Workaround for Docker for Windows in Git Bash.
docker()
{
(export MSYS_NO_PATHCONV=1; "docker.exe" "$#")
}
You may need to do the same for docker-compose