Skip to main content
2 of 2
Python is different from PHP
sourcejedi
  • 53.6k
  • 23
  • 179
  • 337

I don't know of any program that takes a parameter and sends it over a tcp connection.

However you have sort of answered your own question somewhat within your comments, specifically with the following line.

ENTRYPOINT ["/bin/sh", "-c", "mycommand"]

I appreciate that you seem to want the minimalist footprint of applications in your image, but I believe the best solution is to have a shell and netcat., then use your original command. Well at least to test whatever you are trying to do.

If at the end of the day, you want to drop back to only one executable, you'll have to write your own program to do it.

One thought, I see this example, shows setup of Python to run a script,

FROM python:2.7-slim AS build-env
ADD . /app
WORKDIR /app

FROM gcr.io/distroless/python2.7
COPY --from=build-env /app /app
WORKDIR /app
CMD ["hello.py", "/etc"]

which might be easier/quicker than developing a C program to do it all, but then effectively you are using Python as the SHELL. Lastly, if you think socat would do what you want, could you use socat to read from a file (which you include in your image), and that file contains your literal string.

X Tian
  • 10.7k
  • 3
  • 35
  • 51