Example Dockerfile

adamkdean

Adam K Dean

Posted on June 10, 2014

Example Dockerfile

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

# DOCKER-VERSION 0.9.1

FROM ubuntu
MAINTAINER Adam K Dean

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

EXPOSE 80

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
💖 💪 🙅 🚩
adamkdean
Adam K Dean

Posted on June 10, 2014

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related