While executing below script,
sudo docker run -volume "$PWD:/build" -volume "~/.m2:/root/.m2" -volume "~/.build:/root/.build"`
i am getting below error:
docker: invalid reference format.
See 'docker run --help'.
OS using is ubuntu-18. Followed some stackoverflow threads, but missing something.
sudo docker run -volume "$PWD:/build" -volume "~/.m2:/root/.m2" -volume "~/.build:/root/.build"
Your command has several issues:
-volume "$PWD:/build" is not proper syntax, you should use --volume "$PWD:/build" or -v "$PWD:/build"
you are missing an image name: docker run require you to specify which image to run, for example maven:3-jdk-8
it seems you are trying to run a Maven build, you should also specify the working directory with -w and Maven goals
For example:
sudo docker run -v "$PWD:/build" -w /build -v "~/.m2:/root/.m2" -v "~/.build:/root/.build" maven:3-jdk-8 mvn clean package
Related
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.
I am trying to run a GUI created using tkinter on Docker.
This is the docker run command:
docker run -u=$(id -u $USER):$(id -g $USER) -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix:rw -v $(pwd)/app:/app --rm tkinter_in_docker
I am getting the error:
unknown shorthand flag: 'g' in -g
See 'docker run --help'.
What is the correct way to run to get the desired results?
I'm trying to build a docker image for my project.
The docker image could be found here: https://hub.docker.com/r/haipengzhang/merchant_score_project
The corresponding docker file is:
FROM continuumio/anaconda3
RUN apt-get update
RUN pip install lightgbm && \
pip install docopt==0.6.2 && \
pip install deap
When I try to run the project in this docker image with make commands under my project's repo:
docker run --rm -v /$(pwd):/home/xxx/ haipengzhang/merchant_score_project make -C /home/xxx/ clean
I get the following error:
docker: Error response from daemon: OCI runtime create failed: container_linux.go:349: starting container process caused "exec: \"make\": executable file not found in $PATH": unknown.
Could anybody please help? Thanks!
The reason
I now know what happend here. When this question was originally asked, the image in question did not have the make command inside it.
Adding RUN apt-get install -y build-essential to the Dockerfile solves the issue. But, this image is built on dockerhub, so when the image was rebuilt after adding this instruction - it was not refreshed locally. You would actively need to pull the image again like I mention later in this answer.
I verified this, but rebuilding the image from your original Dockerfile definition and confirming that make is not in that image.
Original answer text
I checked, and the image haipengzhang/merchant_score_project does infact have have the make command in the path /usr/bin/make, and it is executable. The user in the image is root, and I am able to start the make command just fine.
There is a little problem with your docker run command, but I do not think that it is related to the issue:
You should not preceed the $(pwd) command with a / in the volume mapping. Try this instead:
docker run --rm -v $(pwd):/home/xxx/ haipengzhang/merchant_score_project make -C /home/xxx/ clean
The error that you are getting, idicates that the make command cimply cannot be found in the path or local working directory inside the image - if I try to pass a nonexisting command, I get the same error:
docker run --rm -v $(pwd):/home/xxx/ haipengzhang/merchant_score_project blabla
I get the same output:
docker: Error response from daemon: OCI runtime create failed:
container_linux.go:349: starting container process caused "exec: \"blabla\": executable file not found in $PATH": unknown.
This leads me to believe that there is something out of order with the revision of the image, I would be concerned that you do not have the latest image locally?
To refresh the local image:
docker image rm haipengzhang/merchant_score_project:latest
docker pull haipengzhang/merchant_score_project
You could try debugging the image with somthing like:
docker run --rm -v $(pwd):/home/xxx/ haipengzhang/merchant_score_project which make
docker run --rm -v $(pwd):/home/xxx/ haipengzhang/merchant_score_project ls -la /usr/bin/make
docker run --rm -v $(pwd):/home/xxx/ haipengzhang/merchant_score_project ls -la /home/xxx
And see if you get some indication that something is out of place
I need to create a container for which I'm able to create new images.
My first guest was to run docker on docker but found that the right
way to do this was using the --privileged argument so the container
has access to the docker daemon.
For this I'm runnin the following comand:
docker run --privileged -v /var/run/docker.sock:/var/run/docker.sock -v /home/user/container_data:/app/app -d -p 5100:5100 mcf2:latest
I'm using -v /home/user/container_data:/app/app because I'm creating the folder for the new images from
templates for flask apps and saving them on that directory.
One of the files I'm creating from the templates is 'create_image.sh' which has the docker build statement E.G.
'docker build -t new_container:latest .'
for that I'm running the following code inside the running container:
bash_path= 'app/classification_model/create_image.sh'
subprocess.call([bash_path],shell=True)
But I always get this error:
/bin/sh: 1: app/model/create_image.sh: docker: not found
But the file does exist, if do ls in the container 'app/' is in the list of folders
I have also checked the bind directory and
'/home/user/container_data/classification_model/create_image.sh'
Does exist.
I have tried changing bash_path to
bash_path= '/app/classification_model/create_image.sh'
and
bash_path= '/app/app/classification_model/create_image.sh'
But get the same error for all the cases
**EDIT: **
I have changed the Docker file to:
From docker:dind
FROM ubuntu:18.04
RUN apt-get update -y && \
apt-get install -y python3-pip python3-dev
...
...
And run again:
docker run --privileged -v /var/run/docker.sock:/var/run/docker.sock -v /home/user/container_data:/app/app -d -p 5100:5100 mcf2:latest
I'm still getting the same error:
/bin/sh: 1: docker: not found
You are mixing two thing
Docker in Docker
Docker in Docker with host Docker Socket
In the both cases, Docker should be installed in the container, it does not mean by mounting -v /var/run/docker.sock:/var/run/docker.sock this any container will able to launch or run docker command.
In the first option, it will start containers as a child container.
In the second option, the container will have access to the Docker socket, and will, therefore, be able to start containers. Except that instead of starting “child” containers, it will start “sibling” containers.
updated:
Docker offical dind image is alpine based so you can install using apk instead of apt.
FROM docker:dind
RUN apk add --no-cache python3 python3-dev
https://pkgs.alpinelinux.org/packages
I'm trying to mount a volume on a container so that I can access files on the server I'm running the container. Using the command
docker run -i -t 188b2a20dfbf -v /home/user/shared_files:/data ubuntu /bin/bash
results in the error
docker: Error response from daemon: OCI runtime create failed:
container_linux.go:296: starting container process caused "exec: \"-v\":
executable file not found in $PATH": unknown.
I'm not sure what to do here. Basically, I need to be able to access a script and some data files from the host server.
The docker command line is order sensitive. After the image name, everything passed is a command that runs inside the container. For docker, the first thing that doesn't match an expected argument after the run command is assumed to be the image name:
docker run -i -t 188b2a20dfbf -v /home/user/shared_files:/data ubuntu /bin/bash
That tries to run a -v command inside your image 188b2a20dfbf because -t takes no value.
docker run -i -t -v /home/user/shared_files:/data 188b2a20dfbf /bin/bash
That would run bash in that same image 188b2a20dfbf.
If you wanted to run your command inside ubuntu instead (it's not clear from your example which you were trying to do), then remove the 188b2a20dfbf image name from the command:
docker run -i -t -v /home/user/shared_files:/data ubuntu /bin/bash
Apparently, on line 296 on your .go script you is referring to something that can't be found. Check your environment variables to see if they contain the path to that file, if the file is included in the volume at all, etc.
188b2a20dfbf passed to -t is not right. -t is used to get a pseudo-TTY terminal for the container:
$ docker run --help
...
-t, --tty Allocate a pseudo-TTY
Run docker run -i -t -v /home/user/shared_files:/data ubuntu /bin/bash. It works for me:
$ echo "test123" > shared_files
$ docker run -i -t -v $(pwd)/shared_files:/data ubuntu /bin/bash
root#4b426995e373:/# cat /data
test123