skip to Main Content

I am trying to build a Kafka-Connect image in Docker:

FROM confluentinc/cp-kafka-connect

RUN confluent-hub install --no-prompt wepay/kafka-connect-bigquery:1.6.1
RUN confluent-hub install --no-prompt confluentinc/connect-transforms:latest

RUN mkdir -p /usr/share/landoop-plugins
COPY kafka-connect-redis-1.2.2-2.1.0-all.jar /usr/share/landoop-plugins/

but it runs as appuser

Step 4/4 : RUN id
 ---> Running in d2094f6336a7
uid=1000(appuser) gid=1000(appuser) groups=1000(appuser)

so if I want for example

RUN mkdir -p /usr/share/landoop-plugins

it stops because of root privilages:

mkdir: cannot create directory '/usr/share/landoop-plugins': Permission denied
The command '/bin/sh -c mkdir -p /usr/share/landoop-plugins' returned a non-zero code: 1

I can add USER root at the beginning of Dockerfile:

Step 3/15 : RUN id
 ---> Running in 6255e2e7ff81
uid=0(root) gid=0(root) groups=0(root)

but then if I ran the container, I am logged as appuser which causes problems with permissions:
[appuser@connect ~]$.

Actually, in source image
confluentinc/cp-kafka-connect:6.0.0
there is a layer USER appuser so my question is how can I build my image as root and then login as root and do not use appuser user. I’ve tried and USER root does not help.

Is it somehow connected with groups?

groups
gignac sudo docker

I tried docker build and sudo docker build as well

2

Answers


  1. I do something similar, when I need to create my own plugin to Kafka Connect but I don’t exactly do it as root.
    Simply I put my jars in a place I have permission to write and just configure the plugins Environment Setting

    something like this:

    FROM    confluentinc/cp-kafka-connect:5.5.2
    
    ENV     CONNECT_PLUGIN_PATH='/usr/share/java,/usr/share/confluent-hub-components'
    
    COPY    converter/* /usr/share/java/kafka-serde-tools/
    COPY    format/* /usr/share/java/kafka-connect-storage-common/
    

    would this not work?

    Login or Signup to reply.
  2. For installing packages and troubleshooting, we would require root user. Using version 5.5.3 does the trick wherein the APPUSER is not created and root is loaded by default.
    The version can be verified by

    http://localhost:8083/connectors
    

    which provides the version details.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search