DEV Community 👩‍💻👨‍💻

Cover image for Example Dockerfile
Adam K Dean
Adam K Dean

Posted on

Example Dockerfile

Here is an example Dockerfile. It installs nginx and adds /src to the wwwroot. Make sure that the files are 755.


FROM ubuntu

RUN apt-get update
RUN apt-get -y install nginx

RUN echo "daemon off;" >> /etc/nginx/nginx.conf
ADD default /etc/nginx/sites-available/default
ADD /src /var/www


CMD ["nginx"]
Enter fullscreen mode Exit fullscreen mode

FROM defines the base image.

RUN runs a command, use it to install software for example.

ADD adds local files to the container.

EXPOSE exposes a port so that the host can map a port to tunnel to it.

CMD defines the command that will be run when the container starts. There can only be one command, if there are multiple, the last one will be used. You can pass parameters to it like so:

CMD ["service", "parameter"]
Enter fullscreen mode Exit fullscreen mode

Top comments (0)

🔠 Find your favorite font

You can change your default font in Settings.