Your browser was unable to load all of the resources. They may have been blocked by your firewall, proxy or browser configuration.
Press Ctrl+F5 or Ctrl+Shift+R to have your browser try again.

Docker: Absolut path for mounting volumes of host #4673

adrian.hugentobler ·

Hi,
I'm trying to create a "Docker -> Shell/Bash Command" step and try to add volume mounts where I want to mount paths of my host machine to the docker image.
I see that the "source path" is described as "Specify a path relative to configuration workspace to be used as mount source". Is this really the only option? Is there no possibility to use absolute paths?

When I want to give the docker image a folder like "/etc/ssl/certs" or a path to a repo that I have in "/home/user/myRepo" then I would have to step back multiple times from workspace until I can finally step to the correct folder.
Instead of
Source path: /home/user/myRepo
I would have to set
../../../../../home/user/myRepo

Is this the only option I have?

Also are some host paths like "/etc/ssl/certs" that are automatically mounted by quickbuild?

Thanks in advanced,
Adrian

  • replies 9
  • views 41
  • stars 1
robinshen ADMIN ·
adrian.hugentobler ·

Thanks Robin!

One more question regarding the docker step.
There is an "Interpreter" option which then generates a --entrypoint parameter in the docker command, however I would like to leave this empty and not set this parameter.
Currently that is not possible. Could this be changed or is there a reason why this is a mandatory option?

robinshen ADMIN ·

The shell/batch command needs this setting to interprete commands. If you just need to invoke docker container with its entrypoint, maybe the run docker container step is what you need?

adrian.hugentobler ·

This --entrypoint parameter causes a skip of the user creation of the docker image. Therefore I'm root inside the container which causes me a problem.
I can't use --user parameter in "options" field of quickbuild because the user that I want doesn't exist because of the before mentioned skip.

Maybe using this "docker shell" step is wrong.
My goal of that step is to:

  • Run docker image
  • Run a build inside image (as normal user)
  • Done

Currently I'm using normal shell step and do the docker commands from there.
Using only the "run docker container" step might also be an option but with the "docker shell" step I can't find a solution at the moment.

robinshen ADMIN ·

How do you use this image without QB? Is entrypoint of the image starts a shell so that you can run specified commands inside it?

adrian.hugentobler ·

Yes, wihtout QB I use "docker run" command, that starts me a shell where I then run build commands.

In QB I use now step of type "Shell/Batch Command".
Then run "docker run" command and pass the docker run command a script to run inside image.

Run docker command:

docker run --rm -it \
  -v "${PWD}":/home/"${docker_user}"/"${docker_workdir}" \
  -v "${HOME}"/.gitconfig:/home/"${docker_user}"/.gitconfig:ro \
  -v /tmp/.X11-unix:/tmp/.X11-unix \
  -v "${HOME}"/.Xauthority:/home/"${docker_user}"/.Xauthority:rw \
  -v /etc/ssl/certs/:/etc/ssl/certs/:ro \
  --workdir=/home/"${docker_user}"/"${docker_workdir}" \
  secodocker/clea-os-builder:22.04 --username="${docker_user}"

Build command inside docker image:

. ./seco-setup.sh -d seco_intel_clea-os_embedded
. ./seco-setup.sh -c
bitbake seco-clea-os-image
drdt ·

In one of my team's projects, they are able to accomplish this by passing additional "-v" parameters in the "Options" field of the step. I don't like this solution; it makes the code less readable, but it does allow more flexibility since they can use a variable to have different mounts for different child configurations AND declare mounts to be read-only:

Options: [ --hostname ${vars.getVariable("friendlyName")} ${vars.getValue("customMountParams")} ]
Variable customMountParams = [ -e MAVEN_ARGS="-gs /tmp/settings/.m2/settings.xml" -v /home/build/.m2:/tmp/settings/.m2:ro" ]

My preferred solution is to copy the relevant files into the configuration workspace so that everything required is in one place.

robinshen ADMIN ·

You may use "run container step" in this case:

  1. Put your build commands into a shell script
  2. Mount the directory containing the shell script into container
  3. Specify path to build script inside container as container argument

PS: QB 15.0.31 supports to mount absolute path into container now

adrian.hugentobler ·

Great, thanks for the quick replies and support of absolute paths.
I'll try this to see what suits us best.