0

I am running the following Docker container from these Dockerfiles:

FROM debian:wheezy
MAINTAINER authors "authors@gm.com"
RUN groupadd -r -g 2200 example && \
useradd -rM -g example -u 2200 example
ENV APPROOT="/app" \
APP="mailer.sh" \
VERSION="0.6"
LABEL base.name="Mailer Archetype" \
 base.version="${VERSION}"
WORKDIR $APPROOT
ADD . $APPROOT
ENTRYPOINT ["/app/mailer.sh"]
EXPOSE 33333

and

FROM dockerinaction/mailer-base:0.6
COPY ["./log-impl", "${APPROOT}"]
RUN chmod a+x ${APPROOT}/${APP} && \
chown example:example /var/log
USER example:example
VOLUME ["/var/log"]
CMD ["/var/log/mailer.log"]

where the mailer.sh is:

#!/bin/sh
printf "Logging Mailer has started.\n"
while true
do
 MESSAGE=$(nc -l -p 33333)
 printf "[Message]: %s\n" "$MESSAGE" > $1
 sleep 1
done

All starts. But I want to test it. So i tried:

  1. from the host to run "nc 33333" -> nothing happens!
  2. to attach to the container: "docker exec -it /bin/bash" but then it does not recognize basic commands like "ps", "vi", "nc"...

So I am afraid my script is just not running. Why is that?

thanks

toto'
  • 1,325
  • 1
  • 17
  • 36
  • I think what is missing is the way you map the port to your local machine. The Publish a container’s port(s) to the host flag can be used for that `docker run -p 33333:33333 imageName` – abelgana Jun 17 '19 at 20:43
  • @abelgana thanks. Actually I tried to start it in that way too but unfortunately no difference. – toto' Jun 18 '19 at 06:46
  • I think I understand why may happen, by looking at this: https://stackoverflow.com/questions/46142861/running-netcat-inside-docker-container I think that "nc" is not installed by default in the debian:wheezy image. – toto' Jun 18 '19 at 08:33

0 Answers0