Docker entry point cannot find directory/file


I’m trying to run a simple Linux program that interfaces with /dev/net/tun in a Docker container. My project consists of three files, ctuna.c, the source file for my program which contains a call to open("/dev/net/tun", ...), a Makefile and the following Dockerfile which builds and runs my program:

FROM ubuntu:latest AS base

RUN set -ex; 
    apt-get update; 
    apt-get install -y build-essential libcap-dev

FROM base as build

RUN set -ex; 
    mkdir -p /usr/src

COPY . /usr/src/ctuna

RUN set -ex; 
    cd /usr/src/ctuna; 
    make install

FROM base as run

COPY --from=build /usr/local/bin /usr/local/bin

RUN set -ex; 
    mkdir -p /dev/net; 
    mknod /dev/net/tun c 10 200

ENTRYPOINT ["ctuna"]

Building the image works but when I run it, ctuna cannot find /dev/net/tun. What am I doing wrong?

Source: Docker Questions

Categorised as docker, dockerfile Tagged ,


Leave a Reply

Still Have Questions?

Our dedicated development team is here for you!

We can help you find answers to your question for as low as 5$.

Contact Us