I have created docker images using the below Dockerfile.
 FROM ubuntu
 RUN apt-get update \
  && DEBIAN_FRONTEND=noninteractive apt-get install -y \
    net-tools \
  && apt-get clean \
  && rm -rf /var/lib/apt/lists/*
RUN apt-get update \
  && DEBIAN_FRONTEND=noninteractive apt-get install -y \
    netcat \
  && apt-get clean \
  && rm -rf /var/lib/apt/lists/*
EXPOSE 1234
ENTRYPOINT bin/bash
CMD ["nc", "-l", "1234"]
I created image from the above docker file and run the docker container using the image by running below command.
docker run -d  -i -p 1234:1234 --name daemon  nc-ubuntu nc -l 1234
In another terminal, I run the below command.
telnet localhost 1234
I got the below output.
$ telnet localhost 1234
Trying ::1...
Connected to localhost.
Escape character is '^]'.
Connection closed by foreign host.
I am trying this as this is sample from book docker in practice in chapter 2 by manning for running docker as daemon process.
As per author I should get below result.
$ telnet localhost 1234
Trying ::1...
Connected to localhost.
Escape character is '^]'.
hello daemon
Any idea why I'm not getting expected output.