I want to use docker volume so that I can mount two different folders in a container.
I am using multiple docker volume statements in a single command but it is not woking. I am getting "invalid reference format"
I am trying this command-
sudo docker run -d -p 10010:8080 -v /Desktop/Jbilling/digilab4u-billing/jbillings/bin/hsql:/opt/jbilling-community-4.1.1/bin/hsql -v /Desktop/Jbilling/digilab4u-billing/jbilling:opt/jbilling-community-4.1.1/jbilling jbilling-community-4.1.1
Could anyone help me out with this
Thanks
You are not using image_name
sudo docker run -d -p 10010:8080 -v /Desktop/Jbilling/digilab4u-billing/jbillings/bin/hsql:/opt/jbilling-community-4.1.1/bin/hsql -v /Desktop/Jbilling/digilab4u-billing/jbilling:opt/jbilling-community-4.1.1/jbilling jbilling-community-4.1.1 IMAGE_NAME
Related
Tks all, idk why, but now its working
I learn to use docker. I try mount a host directory in a Docker container: >docker run -it -v /Users/Kell/Desktop/data:/home/data 77
And this is error: docker: Error response from daemon: error while creating mount source path '/Users/Kell/Desktop/data': mkdir /Users: file exists.
**I use windows and docker 20.10.12, 77 is imageID **
I tried in another disk and tried many ways but still not working. Can u help me ?
If you learning docker from scratch it is recommended to use --mount and not -v anymore: Mount > v
The syntax of --mount and -v differs, so here you' find both: How to mount
Path style in Windows depends on the console you are using. Some are just working in one and not in another.
Windows-Style: docker run --rm -ti -v C:\Users\user\work:/work alpine
Pseudo-Linux-Style in Windows: docker run --rm -ti -v /c/Users/user/work:/work alpine as well as //c/
Inside WSL: docker run --rm -ti -v /mnt/c/Users/user/work:/work alpine
See: Path conversion in Windows
I was following this guide on customizing MySQL databases in Docker, and ran this command multiple times after making tweaks to the mounted sql files:
docker run -d -p 3306:3306 --name my-mysql -v /Users/pneedham/dev/docker-testing/sql-scripts:/docker-entrypoint-initdb.d/ -e MYSQL_ROOT_PASSWORD=supersecret -e MYSQL_DATABASE=company mysql
On all subsequent executions of that command, I would see an error like this:
docker: Error response from daemon: Conflict. The container name "/my-mysql" is already in use by container "9dc103de93b7ad0166bb359645c12d49e0aa4a3f2330b5980e455cec24843663". You have to remove (or rename) that container to be able to reuse that name.
See 'docker run --help'.
What I'd like to know is whether that docker run command can be modified to auto-kill the previous container (if it exists)? Or if there is a different command that has the same desired result.
If I were to create a shell script to do that for me, I'd first run docker ps -aqf "name=mysql" and if there is any output, use that resulting container ID by running docker rm -f $containerID. And then run the original command.
docker run command has a --rm arguments that deletes the container after the run is completed. see the docs . So, just change your command to
docker run --rm -d -p 3306:3306 --name my-mysql -v /Users/pneedham/dev/docker-testing/sql-scripts:/docker-entrypoint-initdb.d/ -e MYSQL_ROOT_PASSWORD=supersecret -e MYSQL_DATABASE=company mysql
I did
docker run -v /jenkins_home:/var/jenkins_home jenkins/jenkins:alpine
on Windows (with docker installed as a linux container).
However, after configuring jenkins on that container, I now wanted to transfer the data in that /jenkins_home volume into a C:\jenkins_home folder on my local windows host machine\another machine.
Any way I can get the data from the /jenkins_home to c:/jenkins_home?
I know I should have made it
docker run -v c:/jenkins_home:/var/jenkins_home jenkins/jenkins:alpine
at the start but mistakes were made and I was wondering how do I fix that as the above suggestion?
Tried running
docker run -it -p 8080:8080 -p 50000:50000 --volumes-from jenkins_old -v c:/jenkins_home:/var/jenkins_home --name jenkins_new jenkins/jenkins:alpine
but it doesn't transfer the data over using the new c:\jenkins_home folder
docker run -v /jenkins_home:/var/jenkins_home jenkins/jenkins:alpine
Can't get the data to transfer over from the /jenkins_home folder to c:\jenkins_home folder.
I don't know where the /jenkins_home would map to on windows, but you could try this:
docker run -it --rm -v /jenkins_home:/from -v c:\jenkins_home:/to alpine cp -r /from /to
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
I am following this docker user guide: Managing Data in Containers
It seem to be a error at "Mount a Host File as a Data Volume" part,
$ sudo docker run --rm -it -v ~/.bash_history:/.bash_history ubuntu /bin/bash
I test it in my mac version docker, it should be like this:
$ sudo docker run --rm -it -v ~/.bash_history:/root/.bash_history ubuntu /bin/bash
I am not sure if am I correct about this.
You can't use -v option with relative path. You need to use absolute path instead:
sudo docker run --rm -it -v /home/<your_user>/.bash_history:/.bash_history ubuntu /bin/bash