OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

Docker with Python and Benthos

  • Thread starter Thread starter Nicolò Fiorentini
  • Start date Start date
N

Nicolò Fiorentini

Guest
I am doing a project where there is a benthos script that insert some data into a cassandra db, but during the execution, with a function, benthos call a python script , that create and populate the cassandra database. I am trying building with docker:

  • i need to install python and Benthos
  • i need to install the python library for cassandra
  • like cmd , to start the benthos script

docker-compose that create 3 different service:

  • one for the db
  • one for the Python script
  • one for the Benthos script

dockerfile

Code:
FROM alpine:latest

WORKDIR /home/

RUN apk add --no-cache python3 py3-pip

RUN apk add --no-cache curl unzip

RUN mkdir -p /root/.local/bin && \
    curl -LO https://github.com/redpanda-data/redpanda/releases/latest/download/rpk-linux-amd64.zip && \
    unzip rpk-linux-amd64.zip -d ~/.local/bin/ 

RUN pip3 install --break-system-packages cassandra-driver

COPY src/main.yaml /src/main.yaml
COPY src/db.py /src/db.py

USER 1000

CMD ["benthos","-c", "./src/main.yaml"]

There, the image can't see "benthos","-c" and gave me this type of error:

Code:
Error response from daemon: failed to create task for container: failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: exec: "benthos": executable file not found in $PATH: unknown


Error response from daemon: failed to create task for container: failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: exec: "-c": executable file not found in $PATH: unknown

I don't know if is the right image for this specific project.

Docker-compose

Code:
services:
  benthos:
    image: benthos-study
    build:
     context: .
     dockerfile: ./Dockerfile  
    ports:
      - 8010:4195
    volumes:
      - ./src:/home/src/
    container_name: benthos-container
    stdin_open: true
    tty: true
    depends_on:
      database:
        condition: service_healthy
        
  app:
    build: 
      context: .
      dockerfile: ./Dockerfile
    volumes:
      - ./src:/home/src/
    container_name: python-container
    depends_on:
      database:
        condition: service_healthy

  database:
    image: cassandra:latest
    ports:
      - 9042:9042
    container_name: cassandra-container
    healthcheck:
      test: ["CMD-SHELL", "cqlsh -u cassandra -p cassandra -e 'DESCRIBE KEYSPACES'"]
      interval: 30s
      timeout: 10s
      retries: 5

I don't know if is right, because i can't execute until the docker stop give me error.

looking on internet and documentation
<p>I am doing a project where there is a benthos script that insert some data into a cassandra db, but during the execution, with a function, benthos call a python script , that create and populate the cassandra database.
I am trying building with docker:</p>
<ul>
<li>i need to install python and Benthos</li>
<li>i need to install the python library for cassandra</li>
<li>like cmd , to start the benthos script</li>
</ul>
<p>docker-compose that create 3 different service:</p>
<ul>
<li>one for the db</li>
<li>one for the Python script</li>
<li>one for the Benthos script</li>
</ul>
<p>dockerfile</p>
<pre><code>FROM alpine:latest

WORKDIR /home/

RUN apk add --no-cache python3 py3-pip

RUN apk add --no-cache curl unzip

RUN mkdir -p /root/.local/bin && \
curl -LO https://github.com/redpanda-data/redpanda/releases/latest/download/rpk-linux-amd64.zip && \
unzip rpk-linux-amd64.zip -d ~/.local/bin/

RUN pip3 install --break-system-packages cassandra-driver

COPY src/main.yaml /src/main.yaml
COPY src/db.py /src/db.py

USER 1000

CMD ["benthos","-c", "./src/main.yaml"]
</code></pre>
<p>There, the image can't see <code>"benthos","-c"</code> and gave me this type of error:</p>
<pre><code>Error response from daemon: failed to create task for container: failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: exec: "benthos": executable file not found in $PATH: unknown


Error response from daemon: failed to create task for container: failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: exec: "-c": executable file not found in $PATH: unknown
</code></pre>
<p>I don't know if is the right image for this specific project.</p>
<p>Docker-compose</p>
<pre><code>services:
benthos:
image: benthos-study
build:
context: .
dockerfile: ./Dockerfile
ports:
- 8010:4195
volumes:
- ./src:/home/src/
container_name: benthos-container
stdin_open: true
tty: true
depends_on:
database:
condition: service_healthy

app:
build:
context: .
dockerfile: ./Dockerfile
volumes:
- ./src:/home/src/
container_name: python-container
depends_on:
database:
condition: service_healthy

database:
image: cassandra:latest
ports:
- 9042:9042
container_name: cassandra-container
healthcheck:
test: ["CMD-SHELL", "cqlsh -u cassandra -p cassandra -e 'DESCRIBE KEYSPACES'"]
interval: 30s
timeout: 10s
retries: 5
</code></pre>
<p>I don't know if is right, because i can't execute until the docker stop give me error.</p>
<p>looking on internet and documentation</p>
 

Latest posts

Top