Cannot connect to server running on host from Dockerfile / image build
First you have to start netcat listening in the background.
$ netcat -l 3440 &amp;

Then build your Dockerfile.

#
# Ubuntu Dockerfile
#
# https://github.com/dockerfile/ubuntu
#

# Pull base image.
FROM ubuntu:14.04

# Install.
RUN \
  sed -i 's/# \(.*multiverse$\)/\1/g' /etc/apt/sources.list &amp;&amp; \
  apt-get update &amp;&amp; \
  apt-get -y upgrade &amp;&amp; \
  apt-get install -y build-essential &amp;&amp; \
  apt-get install -y software-properties-common &amp;&amp; \
  apt-get install -y byobu curl git htop man unzip vim wget &amp;&amp; \
  rm -rf /var/lib/apt/lists/*


# Set environment variables.
ENV HOME /root

# Define working directory.
WORKDIR /root
RUN apt-get install -y netcat
RUN nc localhost 3440 | tar -x -O &gt; ores-$(date +%s.%N).tgz
# Define default command.
CMD ["bash"]