How to use docker run command in terminal? - docker

When I copy them to the terminal I get an error: "docker run" requires at least 1 argument.
I don't know why, should I separate them somehow separately or should the whole command go the first time?

You have to add line breaks and your image name
docker run \
--name example-chris \
-v /home/Projects/example-chris/src/main/resources/application.properties:/config/application.properties \
-v SOME_SOURCE:/etc/ssl/certs/ca-certificates.crt \
--rm \
-p 8081:8080 \
SOME_IMAGE_NAME

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.

what is docker run -w flag?

Came across a docker run command that uses -w flag.
docker run -v $(pwd):/project \
-w /project \
-p 8081:8081 \
gcr.io/base-project/myoh:v1
Any idea what the -w flag is for?
Just run docker run --help in your shell.
-w, --workdir string Working directory inside the container
https://docs.docker.com/engine/reference/run/#workdir

Question about command to execute when running Jenkins image

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

How to run enlightenment wayland in docker container?

I am trying to run enlightenment(https://www.enlightenment.org/start) in a docker container,previously enlightenment is based on X11,but the latest version of enlightenment support wayland. As I searched,we can use the -v parameter when use the "docker run" command to start a docker image like :
$ docker run -it \
--net host \ # may as well YOLO
--cpuset-cpus 0 \ # control the cpu
--memory 512mb \ # max memory it can use
-v /tmp/.X11-unix:/tmp/.X11-unix \ # mount the X11 socket
-e DISPLAY=unix$DISPLAY \ # pass the display
-v $HOME/Downloads:/root/Downloads \ # optional, but nice
-v $HOME/.config/google-chrome/:/data \ # if you want to save state
--device /dev/snd \ # so we have sound
--name chrome \
jess/chrome
(Reference: https://blog.jessfraz.com/post/docker-containers-on-the-desktop/)
But this is based on X11.Currently I do not use the X11,and use the wayland based enlightenment,How can I show my enlightenment UI in docker container?
According to
https://unix.stackexchange.com/questions/330366/how-can-i-run-a-graphical-application-in-a-container-under-wayland
you mount some device such as
/run/user/1000/wayland-0
in your
docker run
command
and here is an extract from
https://github.com/duzy/docker-wayland/blob/master/run.sh
docker run \
--name $container \
-v "$(pwd):/home/user/work" \
--device=/dev/dri/card0:/dev/dri/card0 \
--device=/dev/dri/card1:/dev/dri/card1 \
--device=/dev/dri/controlD64:/dev/dri/controlD64 \
--device=/dev/dri/controlD65:/dev/dri/controlD65 \

Resources