what is docker run -w flag? - docker

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

Related

How to use docker run command in terminal?

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

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.

Docker container exited instantly with code (127)

In the log file I have this error:
./worker: error while loading shared libraries: libcares.so.2: cannot open shared object file: No such file or directory
I tried everything with the library it exists and its linked to the path.
My Dockerfile :
FROM ubuntu:20.04
RUN apt update -y && apt install libssl-dev -y
WORKDIR /worker
COPY build/worker ./
COPY build/lib /usr/lib
EXPOSE 50051
CMD ./worker
My makefile:
all: clean build
build:
mkdir -p build/lib && \
cd build && cmake .. && make
clean:
rm -rf build
clean-containers :
docker container stop `docker container ls -aq`
docker container rm `docker container ls -a -q`
create-workers :
docker run --name worker1 -p 2001:50051 -d workerimage
docker run --name worker2 -p 2002:50051 -d workerimage
docker run --name worker3 -p 2003:50051 -d workerimage
docker run --name worker4 -p 2004:50051 -d workerimage
docker run --name worker5 -p 2005:50051 -d workerimage
docker run --name worker6 -p 2006:50051 -d workerimage
docker run --name worker7 -p 2007:50051 -d workerimage
docker run --name worker8 -p 2008:50051 -d workerimage
docker run --name worker9 -p 2009:50051 -d workerimage
docker run --name worker10 -p 2010:50051 -d workerimage
make sure libcares.so.2 and other shared libraries are present inside /usr/lib of the container.

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

Resources