Docker Community Forums

Share and learn in the Docker community.

Need Help Understanding Shell Differences: During Build vs. Running Container

Background

I’ve been trying to get part of an open source project PX4(https://github.com/PX4/PX4-Autopilot) running inside the docker containers that they provide (https://github.com/PX4/PX4-containers) but I’ve been running into some weird issues that I don’t understand. I’ve been following the guide (https://docs.px4.io/master/en/ros/ros2_comm.html) that goes over setting up the project I’m trying to use.

Issue

If I run their px4io/px4-dev-ros2-foxy container, I can follow the tutorial no problem and get everything running. However, if I try to run the exact same commands inside my own dockerfile, it crashes. I have looked at their entrypoint.sh file and tried sourcing the same files they are sourcing but I have not been able to get it to behave the same way during the build as it behaves while just running a the container. Their entrypoint file is located in the docker container at: /usr/local/bin/entrypoint.sh

I’d really appreciate it if someone could provide more information on the differences between the build environment and a running container as it pertains to the linux shell environment.

Steps to Reproduce

Files: Dockerfile, log.txt

Getting a working example:

  1. docker run -it px4io/px4-dev-ros2-foxy
  2. mkdir -p ~/px4_ros_com_ros2/src
  3. git clone https://github.com/PX4/px4_ros_com.git ~/px4_ros_com_ros2/src/px4_ros_com
  4. git clone https://github.com/PX4/px4_msgs.git ~/px4_ros_com_ros2/src/px4_msgs
  5. cd /root/px4_ros_com_ros2/src/px4_ros_com/scripts
  6. source /opt/ros/foxy/setup.bash && source build_ros2_workspace.bash

Failing to build the Dockerfile:

  1. docker build -t px4 --no-cache .

Could you share the exact error message as a log snippet and post the Dockerfile in a code block (</> icon)?

It would help to lower the barrier for us to understand the issue. Otherwise we would have to re-do all your steps in order to reproduce the problem on our systems.

1 Like

Thanks for the response! I’ve added a log.txt file containing the error I am receiving. Unfortunately, it was too long to paste in a code block.

Step 6 of your example executes two scripts by simply sourcing them. Because they are sourced they are running in the execution context of the current shell - variables declared in the script will be available in the shell (which can have unwanted side effects). I am not sure if this is required due to the design of the scripts or just a “let me try it like this” decition.

First observation: I can see that java sparks up - but does nothing? Though python complains about missing dependencies which lead to all the errors that are scattered all over the logs.

It is almost as if this image (and the dependencies it should provide) is not alligned with what you checked out and try to run.

I would suggest to raise an issue in the maintainers github repository, as this requires knowledge about PX4 - and not “just docker knowledge”.

1 Like

In order to have a real comparability with how it works during docker build, you need to prevent the entrypoint script to be executed:
docker run --rm -ti --entrypoint bash px4io/px4-dev-ros2-foxy