Question about command to execute when running Jenkins image - jenkins

I have questions while using the Jenkins image to check the commands to run the container and leave a question.
I ran the following command.
docker run \
-u root \
--rm \
-p 8080:8080 \
--name jenkins \
-v /Users/newbie/jenkins:/var/jenkins_home \
-v /var/run/docker.sock:/var/run/docker.sock \
jenkins:lts
What does ' : ' and ' -v ' mean in -v /Users/newbie/jenkins:/var/jenkins_home \ on line 6?

-v = Bind mount a volume. See this
It mounts /Users/newbie/jenkins directory on your host to /var/jenkins_home on your container

Related

Docker container disappears upon exiting

The container was created with the commands
docker run --gpus '"'device=$CUDA_VISIBLE_DEVICES'"' --ipc=host --rm -it \
--mount src=$(pwd),dst=/clipbert,type=bind \
--mount src=$OUTPUT,dst=/storage,type=bind \
--mount src=$PRETRAIN_DIR,dst=/pretrain,type=bind,readonly \
--mount src=$TXT_DB,dst=/txt,type=bind,readonly \
--mount src=$IMG_DIR,dst=/img,type=bind,readonly \
-e NVIDIA_VISIBLE_DEVICES=$CUDA_VISIBLE_DEVICES \
-w /clipbert jayleicn/clipbert:latest \
bash -c "source /clipbert/setup.sh && bash" \
But upon exit and running docker ps -a, the container is not listed and it seems like the container is only temporarily created. This has not happened in my previous experience with docker, what may the reason be?
The --rm options tells docker run command to remove the container when it exits automatically.

Docker invalid referenct format

Runing this one Ubuntu 20 . What is wrong?
Using this tutorial
https://docs.vyos.io/en/latest/installation/virtual/docker.html
#docker run -d --rm --name vyos --privileged -v /lib/modules:/lib/modules > vyos:1.4-rolling-202112080318 /sbin/init
docker: invalid reference format.
See 'docker run --help'.
The tutorial (docs.vyos.io) uses the following command:
docker run -d --rm --name vyos --privileged -v /lib/modules:/lib/modules \
> vyos:1.4-rolling-202111281249 /sbin/init
Notice the \ at the end of the first line. This signals a multi-line command, i.e. the command is continued on the next line. The > at the beginning of the 2nd line is a prompt, i.e. not essential for the command. We can rewrite the command, e.g. as oneliner:
docker run -d --rm --name vyos --privileged -v /lib/modules:/lib/modules vyos:1.4-rolling-202111281249 /sbin/init
Or - what I like to do - put each parameter on a separate line:
docker run \
-d \
--rm \
--name vyos \
--privileged \
-v /lib/modules:/lib/modules \
vyos:1.4-rolling-202111281249 \
/sbin/init
All of those are equivalent.

how to change the directory of docker

-- I installed docker on my debian 8
-- I pulled docker-handbrake from https://github.com/jlesage/docker-handbrake
docker pull jlesage/handbrake
and installed it
-- I had 2 drives,
the first one is my OS drive which mounted on /
the second one is my storage drive which mounted on /srv
so the thing I want to do is run handbrake docker directories on /srv with the following command
--name=handbrake \
-p 5800:5800 \
-v /docker/appdata/handbrake:/config:rw \
-v /srv:ro \
-v /srv/HandBrake/watch:/watch:rw \
-v /srv/HandBrake/output:/output:rw \
jlesage/handbrake
but i got this error :
docker: Error response from daemon: invalid bind mount spec "/srv:ro": invalid volume specification: '/srv:ro'.
See 'docker run --help'.
I can do something like this.
--name=handbrake \
-p 5800:5800 \
-v /docker/appdata/handbrake:/config:rw \
-v /srv:/storage:ro \
-v /srv/HandBrake/watch:/watch:rw \
-v /srv/HandBrake/output:/output:rw \
jlesage/handbrake
Or
--name=handbrake \
-p 5800:5800 \
-v /docker/appdata/handbrake:/config:rw \
-v /:/storage:ro \
-v /srv/HandBrake/watch:/watch:rw \
-v /srv/HandBrake/output:/output:rw \
jlesage/handbrake
Note: Make sure you are not changing container directory which /storage:ro . Just change your host directory or path.

Jenkins location in docker, not at /var/jenkins_home

I'm installing Jenkins via docker by following this official guide.
After running command:
docker run \
-u root \
--rm \
-d \
-p 8080:8080 \
-p 50000:50000 \
-v jenkins-data:/var/jenkins_home \
-v /var/run/docker.sock:/var/run/docker.sock \
jenkinsci/blueocean
I'm expecting Jenkins to be installed # /var/jenkins_home, but instead it is being installed # /var/lib/docker/volumes/jenkins-data.
Also there is no such folder as /var/jenkins_home.
Am I missing something. Please suggest.
Thank You
/var/jenkins_home is inside the container. You are using named volume & that's why it's located in /var/lib/docker/volumes/jenkins-data.
Instead, you can use host bind mounts as below to ensure you get the data in /var/jenkins_home on the host machine -
docker run \
-u root \
--rm \
-d \
-p 8080:8080 \
-p 50000:50000 \
-v /var/jenkins_home:/var/jenkins_home \
-v /var/run/docker.sock:/var/run/docker.sock \
jenkinsci/blueocean
Volumes path in case of host mounts has to be absolute else it results in creating a named volume.

How do I choose a folder to store files from Docker?

I've been working on this for hours, but I've mainly found answers relating to Linux.
I'm running Docker in Windows 10, and I'm trying to install some distros from Linuxserver
I can do a basic setup (following a guide that install Jackett a similar way)
docker create --name=jackett \
--restart=always \
-v /home/docker/jackett/config:/config \
-v /home/docker/jackett/downloads:/downloads \
-e PGID=1001 -e PUID=1001 \
-e TZ=Europe/London \
-p 9117:9117 \
linuxserver/jackett
But, I don't understand how to select one of the shared drives I setup, and I have no idea where /home/... is on my hard drive.
How would I set this up to save config and downloads in say:
H:\Documents\Configs
docker volume definitions are in pairs
-v left_side:right_side
where full path of left side is a directory local to the machine where you are executing your docker command from ... your laptop or server ... whereas the right_side is same directory as viewed from inside the freshly launched container ... that is you are mounting a local dir to your container so it can read and write to persist changes even after the container is killed off
For example I want to make visable to my app the dir on my laptop of
/some/full/path/local/dir
and the app will see this as path
/whatever/dir
so syntax would look like this
docker ... skip settings ... -v /some/full/path/local/dir:/whatever/dir
My guess is if your host machine is MS Windows then use Windows \ separators rather than linux / separators
docker ... skip settings ... -v c:\some\full\path\local\dir:/whatever/dir
so this would be linux host syntax
docker create --name=jackett \
--restart=always \
-v /some/config/dir:/config \
-v /some/config/dir:/downloads \
-e PGID=1001 -e PUID=1001 \
-e TZ=Europe/London \
-p 9117:9117 \
linuxserver/jackett
whereas this is MS Windows syntax using \ instead of / as seperator
docker create --name=jackett \
--restart=always \
-v H:\\Documents\\Configs:/config \
-v H:\\Documents\\Configs:/downloads \
-e PGID=1001 -e PUID=1001 \
-e TZ=Europe/London \
-p 9117:9117 \
linuxserver/jackett
UPDATE - notice the double \ which might work on Windows since a single \ just means do an escape on following character ... Also leave as is the last line of above linuxserver/jackett as that is not a path its the docker image name
on ubuntu I just ran below just fine
docker create --name=jackett_stens \
--restart=always \
-v /home/khufu/src/config:/config \
-v /home/khufu/src/config:/downloads \
-e PGID=1001 -e PUID=1001 \
-e TZ=Europe/London \
-p 9117:9117 \
linuxserver/jackett
above output is
khufu#jill ~ $ docker create --name=jackett_stens \
> --restart=always \
> -v /home/khufu/src/config:/config \
> -v /home/khufu/src/config:/downloads \
> -e PGID=1001 -e PUID=1001 \
> -e TZ=Europe/London \
> -p 9117:9117 \
> linuxserver/jackett
Unable to find image 'linuxserver/jackett:latest' locally
latest: Pulling from linuxserver/jackett
f2233041f557: Already exists
53bd17864f23: Pull complete
02efc09c990b: Pull complete
14b057e5c85e: Pull complete
7e03e93fc218: Pull complete
9825bf39efb1: Pull complete
0a74d4d4cac0: Pull complete
34451e5c900f: Pull complete
5453d859f994: Pull complete
d9976cfaf0ba: Pull complete
09ccdb48553d: Pull complete
Digest: sha256:b624cbc75efb40d7dab9a2095653988632a4773ad86e0f5ee2edd877e4178678
Status: Downloaded newer image for linuxserver/jackett:latest
dddfae776bfc32c3a55de1ddc08c04e2574ecb3c950ba9bb88f477e3e240121e
OK so above worked then I launched the image using
docker start jackett_stens
and confirmed it is running by issuing
docker ps

Resources