Could not find `Cargo.toml` running Cargo in docker container - docker

I am using the code:
docker run --rm -v "$(pwd)":/code \
--mount type=volume,source="$(basename "$(pwd)")_cache",target=/code/target \
--mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \
cosmwasm/rust-optimizer:0.12.4
I keep running into this error
error: could not find Cargo.toml in /code or any parent directory

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 run binding container pip site-packages for peristant pip installs

I am trying to bind my pip site-packages docker container directory to my host computer, but on my host computer the directory is empty.
docker run -d \
-p 8080:8080 \
--name "ml-workspace" \
-v "/${PWD}:/workspace" \
--mount type=bind,source=/opt/conda/lib/python3.7/site-packages,target=/workspace/cache/site-packages \
--env AUTHENTICATE_VIA_JUPYTER="password" \
--shm-size 512m \
--restart always \
dagshub/ml-workspace:latest
Also, I am trying to bind the vs studio extensions directory --mount type=bind,source=/root/.vscode/extensions,target=/workspace/cache/extensions, but docker doesn't seem to like . in the path.

Running firefox in a ubuntu docker container on localhost: Unable to init server: Broadway display type not supported:

I am experimenting with running X11 GUI programs from a docker container on localhost:
FROM ubuntu:20.04
RUN apt-get update && apt-get install -y firefox
ARG home=/root
WORKDIR $home
COPY entrypoint.sh .
ENTRYPOINT ["./entrypoint.sh"]
where the entrypont.sh file is:
#! /bin/bash
firefox &
exec bash
Building the image with:
docker build -t firefox-ubuntu-2004 .
And running the container (localhost: Ubuntu 20.04):
XSOCK=/tmp/.X11-unix
XAUTH=/tmp/.docker.xauth
DISPLAY="localhost:0"
xauth nlist $DISPLAY | sed -e 's/^..../ffff/' | xauth -f $XAUTH nmerge -
docker run -it --rm \
-e DISPLAY=$DISPLAY \
-v $XAUTH:$XAUTH \
-v $XSOCK:$XSOCK \
-e XAUTHORITY=$XAUTH \
firefox-ubuntu-2004
The output error message from running the last command is:
Unable to init server: Broadway display type not supported: localhost:0
Error: cannot open display: localhost:0
The --net=host in the docker command should do the job
docker run --name myContainer -it --net=host fromMyimage:latest
along with using host.docker.internal instead of localhost for connecting to the docker's host on OSX.

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.

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