title: docker build - Cannot open TUN/TAP dev /dev/net/tun
body: <p>I'll try build docker image with openvpn connect to HideMyAss VPN.
  Look at Dockerfile:</p>
  
  <pre><code>FROM ubuntu:16.04
  
  RUN apt-get update
  RUN apt-get clean &amp;&amp; apt-get -y update &amp;&amp; apt-get install -y locales curl
  RUN apt-get install -y php apache2 curl openvpn zip unzip bridge-utils
  RUN apt-get install nano
  
  RUN mkdir -p /dev/net &amp;&amp; \
   mknod /dev/net/tun c 10 200 &amp;&amp; \
   chmod 600 /dev/net/tun &amp;&amp; \
   cat /dev/net/tun
  
  COPY tcp/Anguilla.TheValley.TCP.ovpn /etc/openvpn
  COPY tcp/Angola.Luanda.TCP.ovpn /etc/openvpn
  COPY tcp/Belgium.Brussels.TCP.ovpn /etc/openvpn
  COPY tcp/pass.txt /etc/openvpn
  
  EXPOSE 8888
  
  RUN openvpn --config /etc/openvpn/Belgium.Brussels.TCP.ovpn
  </code></pre>
  
  <p>When I try build this code I have an error:</p>
  
  <pre><code>cat: /dev/net/tun: File descriptor in bad state
  </code></pre>
  
  <p>But if I remove this 2 lines: </p>
  
  <pre><code>cat /dev/net/tun
  
  RUN openvpn --config /etc/openvpn/Belgium.Brussels.TCP.ovpn
  </code></pre>
  
  <p>than container successfully build and when I enter to him (docker exec) and run command </p>
  
  <pre><code>openvpn --config /etc/openvpn/Belgium.Brussels.TCP.ovpn
  </code></pre>
  
  <p>then all works fine.</p>
  
  <p>Can somebody help me, why it doesn't work via image building?</p>