Docker : invalid reference format on composer install - docker

I want to install the vendor folder of a project on docker, and I try to use this command:
winpty docker run --rm --interactive --tty \ --volume $(pwd):/app \ composer install
but after running it, I get the error message
C:/Program Files/Docker/Docker/Resources/bin/docker.exe: invalid
reference format.
is there any solution to fix it?

In powershell you should use ${pwd} instead of $(pwd)

Related

Docker command gives me error: could not find `Cargo.toml` in `/contract` or any parent directory. I think this is from a faulty docker command

I am trying to run a contract optimizer for my Secret Network app code. I am pretty sure that this error has nothing to do with Secret Network so that's not relevant. All you need to know is that my app is written in rust. I am 99% sure my problem is the fault of a bad docker command. I am running this command in the same directory of my app's code.
docker run --rm -v "$(pwd)":/contract \
--mount type=volume,source="$(basename "$(pwd)")_cache",target=/code/target \
--mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \
enigmampc/secret-contract-optimizer
I put the above docker command into a script and ran it. I got this in my terminal:
docker: Error response from daemon: invalid mount config for type "volume": invalid mount path: 'C:/Program Files/Git/code/target' mount path must be absolute.
See 'docker run --help'.
I tried to modify the command by adding an extra / to the start of the target value like this:
docker run --rm -v "$(pwd)":/contract \
--mount type=volume,source="$(basename "$(pwd)")_cache",target=//code/target \
--mount type=volume,source=registry_cache,target=//usr/local/cargo/registry \
enigmampc/secret-contract-optimizer
But then I got this error:
error: could not find `Cargo.toml` in `/contract` or any parent directory
So what is wrong with the docker command? I am running it in the same directory as the Cargo.toml file for my app.

Docker not seeing a path

My docker script is this:
docker run --interactive --tty --rm \
--volume=$HOME/neo4j/data:/data \
--volume=$HOME/neo4j/backups:/backups \
neo4j/neo4j-admin:4.4.9 \
neo4j-admin load --database=neo4j --from=/backups/neo4j.dump
When I run it, I'm getting:
docker: invalid reference format.
See 'docker run --help'.
zsh: no such file or directory: --volume=/Users/ironside/neo4j/backups:/backups
zsh: no such file or directory: neo4j/neo4j-admin:4.4.9
But if I do cd $HOME/neo4j/backups and pwd I get /Users/ironside/neo4j/backups. So it exists. Same with the .dump file. It's there.
The data part works, which is very confusing. I'm trying to follow this part from the docs:
https://neo4j.com/docs/operations-manual/current/docker/maintenance/#docker-neo4j-dump
docker run --interactive --tty --rm \
--volume=$HOME/neo4j/data:/data \
--volume=$HOME/neo4j/backups:/backups \
neo4j/neo4j-admin:4.4.9 \
neo4j-admin load --database=neo4j --from=/backups/<dump-name>.dump
What am I missing here?
I'm using a MAC (MacBook Pro (16-inch, 2021)) with Apple M1 Pro chip.

docker: Error response from daemon: invalid volume specification

I'm currently following this tutorial to run a model on Docker that was built using the Google Cloud AutoML Vision:
https://cloud.google.com/vision/automl/docs/containers-gcs-tutorial
I'm having trouble running the container, specifically running this command:
sudo docker run --rm --name ${CONTAINER_NAME} -p ${PORT}:8501 -v ${YOUR_MODEL_PATH}:/tmp/mounted_model/0001 -t ${CPU_DOCKER_GCR_PATH}
I have my environment variables set up right (did an echo $<env_var>). I do not have a /tmp/mounted_model/0001 directory on my local system. My model path is configured to be the model location on the cloud storage.
${YOUR_MODEL_PATH} must be a directory on the host on which you're running the container.
Your question suggests that you're using the Cloud Storage bucket path but you cannot do this.
Reviewing the tutorial, I think the instructions are confusing.
You are told to:
gsutil cp \
${YOUR_MODEL_PATH} \
${YOUR_LOCAL_MODEL_PATH}/saved_model.pb
So, your command should probably be:
sudo docker run \
--rm \
--interactive --tty \
--name=${CONTAINER_NAME} \
--publish=${PORT}:8501 \
--volume=${YOUR_LOCAL_MODEL_PATH}:/tmp/mounted_model/0001 \
${CPU_DOCKER_GCR_PATH}
NB I added --interactive --tty to make debugging easier; it's optional
NB ${YOUR_LOCAL_MODEL_PATH} not ${YOUR_MODEL_PATH}
NB The command should not be -t ${CPU_DOCKER_GCR_PATH} omit the -t
I've not run through this tutorial.

docker: invalid reference format in Mac OS X

I ran the docker run command to run the jenkins image.
But this is the command that was executed in the past, but now an error occurs.
command
docker run -u root —rm -p 8080:8080 —name jenkins \ -v Users/human/jenkins:/var/jenkins_home \
-v /var/run/docker.sock:/var/run/docker.sock \ jenkins
error
docker: invalid reference format.
See 'docker run --help'.
My environment is Mac OS X. What's wrong with me?
It could be the path "Users/human/jenkins" is invalid. If you are using $PWD following the example on Jenkins site, be very careful about possible space character in the "current" path. That would mess up the command and throw out that error message you posted.
It seems like you have a parsing issue for the command above, I have changed this — to --.. this should work:
docker run -u root --rm -p 8080:8080 --name jenkins -v Users/human/jenkins:/var/jenkins_home -v /var/run/docker.sock:/var/run/docker.sock jenkins
Or like this:
docker run -u root --rm -p 8080:8080 --name jenkins \
-v Users/human/jenkins:/var/jenkins_home \
-v /var/run/docker.sock:/var/run/docker.sock \
jenkins

docker --volume format for Windows

I'm trying to take a shell script we use at work to set up our development environments and re-purpose it to work on my Windows environment via Git Bash.
The way the containers are brought up in the shell script are as follows:
docker run \
--detach \
--name=server_container \
--publish 80:80 \
--volume=$PWD/var/www:/var/www \
--volume=$PWD/var/log/apache2:/var/log/apache2 \
--link=mysql_container:mysql_container \
--link=redis_container:redis_container \
web-server
When I run that as-is, it returns the following error message:
C:\Program Files\Docker\Docker\Resources\bin\docker.exe: Error response from daemon: invalid bind mount spec "/C/Users/username/var/docker/environments/development/scripts/var/log/apache2;C:\\Program Files\\Git\\var\\log\\apache2": invalid volume specification: '/C/Users/username/var/docker/environments/development/scripts/var/log/apache2;C:\Program Files\Git\var\log\apache2': invalid mount config for type "bind": invalid mount path: '\Program Files\Git\var\log\apache2' mount path must be absolute. See 'C:\Program Files\Docker\Docker\Resources\bin\docker.exe run --help'.
I did a bunch of googling and documentation reading, but I'm a little overwhelmed by Docker, and I think I got it wrong. I tried setting up the container as follows:
docker run \
--detach \
--name=server_container \
--publish 80:80 \
--volume=/c/users/username/var/www:/var/www \
--volume=/c/users/username/var/log/apache2:/var/log/apache2 \
--link=mysql_container:mysql_container \
--link=redis_container:redis_container \
web-server
It still errors out with a similar error message. If I remove the colon:/var/www it comes up, but it doesn't seem to map those directories properly, that is it doesn't know that C:\users\username\var\www = /var/www
I know I'm missing something painfully dumb here, but when I look at the documentation I just glaze over. Any help would be greatly appreciated.
For people using Docker on Windows 10, an extra / has to be included in the path:
docker run -it -v //c/Users/path/on/host:/app/path/in/docker/container command
(notice an extra / near c)
If you are using Git Bash and using pwd then use an extra / there as well:
docker run -p 3000:3000 -v /app/node_modules -v /$(pwd):/app 09b10e9fda85`
(notice / before $(pwd))
Well, I answered my own question moments after I posted it.
This is the correct format.
docker run \
--detach \
--name=server_container \
--publish 80:80 \
--volume=//c/users/username/var/www://var/www \
--volume=//c/users/username/var/log/apache2://var/log/apache2 \
--link=mysql_container:mysql_container \
--link=redis_container:redis_container \
web-server
Should have kept googling a few minutes longer.
If you want to make the path relative, you can use pwd and variables. For example:
CURRENT_DIR=$(pwd)
docker run -v /"$CURRENT_DIR"/../../test/:/test alpine ls test

Resources