Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [cdt-dev] Building CDT project with docker image
  • From: <Anton.Krug@xxxxxxxxxxxxx>
  • Date: Wed, 10 Feb 2021 18:25:21 +0000
  • Accept-language: en-GB, en-US
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=microchip.com; dmarc=pass action=none header.from=microchip.com; dkim=pass header.d=microchip.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=49zcrXZxpeMcn8WlogJKdP1sF16aPeBhPWf+Fw0wHyI=; b=dMpYcQc++7y5HKO3fTaNElWvnwLxHLrQ8Jk0OeyuJP3Xx/gayuzShG0nIB5HUUWiYJrtmjqFvAOljg0oJlW8Vk4D5i2uphc+QsJzaAsX/MwMe1c8HZRzkSBOHdzYvJhC8OkMF6+jHdZ0VF271ZwRWJs+Z5shXVZHcEQDmTGiMowcD2AkvaEi0xw7td2PLz/5eg2/B9txYH3M8ZigeQnffNdAy+GqmLx4vyKtLD7BjlNppXjjiKimIB/7CQlSEu3iQZRyUna8is35Y3PeJT4viWf+mKvknD7J+a5Wa769QpDM10u7/HYUg2+Z3ErkFV705yk6BF7WknIK1kwrmT2dGQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ONmuM9hR6RU1cRB4fWpRIHE1CcvzZUY0dK1f3uqjGMfUtcuf/Rp0fF9qo2tcsz62LCeFObm/gW4fVbM9LYEsHJglCv29lVxGzUDhF+ZBVz9srH6yPdHcLQO6JALc6mAwHhaFc5VokhtKclqJd/SOz/IpGU6A9+zMmDJF5r19yWXBdQkEtT+7z2emkwG56FP8K7f0Mzu1tu/+iQt8yk4EGQufZgsJ8vK62McctpNp9eK64TDpPoqcgs7dA6fQ8eh9rvgtYwegRXcz97gAyC6fgTc4VRaa6goe6CdmrmeZtphv0rycEZtyfg29si+mRae+5IWq5Ia1OI3HGP8uGQB+3A==
  • Delivered-to: cdt-dev@xxxxxxxxxxx
  • Ironport-sdr: VZS5NwNT3xjVAdMoFtw7uwy2o2tXViWH3umGFV/qQDT8rS2ue3DS0qIK3KM5akfABNa1GYr+93 znYWZFara4QEt/yeKSPGH/X7gY1BfsLPRJAFpAd9THZt8kR823mM/YLxynX34STVcNUXHpL8VW npHRdH5qK5dbliezJ4GzeQY4nH4ZIGK2rtkI+v5ViNnQi2V3rp7VNRw02XEJ/lKpsRhGhnPTSm eXIOUeilx/Stkt205+ONA7SS5BSiFRvvaqLogT9c/LUMhslVzyvKokFIaSeMhehUSQ0iBXDh3G YTM=
  • List-archive: <https://www.eclipse.org/mailman/private/cdt-dev/>
  • List-help: <mailto:cdt-dev-request@eclipse.org?subject=help>
  • List-subscribe: <https://www.eclipse.org/mailman/listinfo/cdt-dev>, <mailto:cdt-dev-request@eclipse.org?subject=subscribe>
  • List-unsubscribe: <https://www.eclipse.org/mailman/options/cdt-dev>, <mailto:cdt-dev-request@eclipse.org?subject=unsubscribe>
  • Thread-index: Adb/vVAA9/ckQKbdT6GOmOP1gS0jYQAA4eaAAABySAAABE2t4AABRtHA
  • Thread-topic: [cdt-dev] Building CDT project with docker image

Do you depend on something else, often the docker images are very small and often not fully functional. Actually I would see the docker images as partially dysfunctional, often very stripped down and mostly headless (both of these are often causes of issues). So I would assume there are few things which you do not miss. Stilly things like not set locale/term, or dependency on X11 (or some specific font) could break a lot of stuff. So far everything I wanted I was able to run in Docker but it always required some helping hand to setup the environment to be able to do so.

 

You can’t run as some user, does that user exist in that docker distro, do you need to create it? You might need create some accompany groups as well.

 

For example because docker runs on root, there is no need to use sudo, and no point to package it, but if some of your scripts or tools actually still want to invoke it (without checking if they are root already) then you might get fail and you might end up installing sudo just to make the scripts happy.

 

Sometimes some stdout/stderr streams can get confused as well making things stuck.

 

Could you run htop or ps-fax frequently to see if there is some processes invoked as their child.

 

From: cdt-dev <cdt-dev-bounces@xxxxxxxxxxx> On Behalf Of Alexis Bouffies
Sent: Wednesday, February 10, 2021 5:55 PM
To: CDT General developers list. <cdt-dev@xxxxxxxxxxx>
Subject: Re: [cdt-dev] Building CDT project with docker image

 

EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe

Hi Morty and Anton,

 

Thanks a lot for you quick answers. When building from the CLI, everything is fine, and when I look at the user, it is “root”. However when I run the image in Eclipse when building through CDT, it seems that the user is 1001 (my user). The access to the files seems fine when I build the image with

 

RUN echo "" >> /etc/bash.bashrc && \

    echo "umask 0000" >> /etc/bash.bashrc

 

at the beginning of the Dockerfile. I have no longer the permission denied issue. However I still have my second issue:

 

We have a python tool installed in the Docker image, and when this tool is called by the make script from the Docker image inside CDT, nothing happens, it seems the tool cannot even be called. While this is working fine when running the image in a terminal on the Ubuntu machine.

 

It seems that from Eclipse when building in a Docker image I cannot specify a user, and it uses the user that started Eclipse. The python tool in question is installed with “pip install” in the Dockerfile. It does not output any error in the CDT console when built in Eclipse, it just does nothing. Am I missing something regarding permission for this specific tool to set in my file?

 

Thanks a lot for your help,

Alexis

 

From: cdt-dev [mailto:cdt-dev-bounces@xxxxxxxxxxx] On Behalf Of Anton.Krug@xxxxxxxxxxxxx
Sent: February 10, 2021 10:42 AM
To: cdt-dev@xxxxxxxxxxx
Subject: Re: [cdt-dev] Building CDT project with docker image

 

Other option is to set UMASK to something wide, so when the files in the docker are created as root, you will still have full power over them as the user:

umask 0000

When generating cotainers you could do automatically so then you do not have to worry about it on each run:

 

RUN echo "" >> /etc/bash.bashrc && \

    echo "umask 0000" >> /etc/bash.bashrc

 

 

Or make a wrapper script which will create the matching user in the container and then execute your script as that user:

 

# get location of this script no matter what your current folder is, this might break between shells so make sure you run bash

LOCAL_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

 

# get current IDs

USER_ID=$(id -u)

GROUP_ID=$(id -g)

 

echo "Mount $LOCAL_DIR into docker, and match the host IDs ($USER_ID:$GROUP_ID) inside the container."

 

docker run -v $LOCAL_DIR:/host_mount -i debian:9.4-slim bash -c "set -euo pipefail && groupadd -r -g $GROUP_ID lowprivgroup && useradd -u $USER_ID lowprivuser -g $GROUP_ID && cd /host_mount && su -c ./runMyScriptAsRegularUser.sh lowprivuser"

 

From: cdt-dev <cdt-dev-bounces@xxxxxxxxxxx> On Behalf Of Moritz Strübe
Sent: Wednesday, February 10, 2021 3:25 PM
To: cdt-dev@xxxxxxxxxxx
Subject: Re: [cdt-dev] Building CDT project with docker image

 

EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe

Hey,

you are running into a classical Docker-Issue: No user-mapping for bind-mounts. For Windows this does not matter, because the folders are shared via some (pretty slow) abstraction layer and are mapped to the appropriate user. When you run your code using Linux, the user within the Docker is either root, which has user id 0, or some created user, which most likely has user id 1000. If you run your code using the root user, all created files belong to root and there are some scripts that don't run as root (mostly for safety reasons). If you run as user with the ID 1000 you won't have access to the files, as the Linux user who owns the files most likely has a different user-id.
VSCode solves this by changing the user-id of the default user after startup.

There are two quick solutions, besides adding support to Eclipse:

* Make sure the user with id 1000 has access to the files. Something you can do on your own system, but is not something you want to support for other people.
* Use root within the docker-image, pass the user-id of the linux-user into the container. Then, in the entrypoint, create a new user with that user-id and change to that user. I however did not research the best way to pass the user-id into the container.
* Similar to the latter, but detect the user-id based on the owner of the the current work-directory.

Cheers
Morty

Am 10.02.2021 um 15:59 schrieb Alexis Bouffies:

Hi everyone,

 

I am running into issues when using the “Build from Docker image” option for the CDT project build. My use case is the following:

 

I have a custom RCP based on Eclipse CDT. This RCP had been ported to Windows, and we are trying to port it to Linux Ubuntu. To build C/C++ projects, we deliver a Docker image to the user, that is linked at project creation. The project is built through a “make” command. We also offer the possibility to build the project in the Docker image in command line mode. Here is what I have so far:

 

  1. In Windows everything works, build in the Docker image from CDT or in Docker from the launched image in the command line
  2. In Linux Ubuntu, the whole build works fine from the command line, but I witnessed the following issues when building from CDT:
    1. I got some “permission denied” errors when calling the compiler installed on the Docker image. Although this has been solved setting the user to “root” when building the Docker image, it makes me wonder what the user is set to when running from CDT?
    2. After setting the user to root in the built Docker image, another issue appears: we have a python tool installed in the Docker image, and when this tool is called by the make script from the Docker image inside CDT, nothing happens, it seems the tool cannot even be called.

 

I do not have extended experience with Linux so there is probably something I am missing there. Any help would be greatly appreciated.

 

Thanks,

Alexis

 

_______________________________________________
cdt-dev mailing list
cdt-dev@xxxxxxxxxxx
To unsubscribe from this list, visit https://www.eclipse.org/mailman/listinfo/cdt-dev

 

-- 
MATHEMA GmbH
Schillerstraße 14 | 90409 Nürnberg
 
Telefon: +49 (0)911 180778-50
E-Mail: moritz.struebe@xxxxxxxxxx | Web: www.mathema.de
 
Geschäftsführer: Andreas Hanke, Thomas Haug
Handelsregister: HR B 35517, Nürnberg/Bayern

Back to the top