7. Dockerfiles
Command
Explanation
FROM
Sets which base image to use
ADD
Lets you add content to the image
CMD
Provides defaults for an executing container, can be used
interchangeably with ENTRYPOINT
ENTRYPOINT
Sets the container up to behave like a single executable
ENV
Passes a variable to all future RUN instructions
EXPOSE
Exposes port(s)
MAINTAINER
Metadata about who owns this
RUN
Executing directive used to build an image
USER
Sets the UID to run the next command as
VOLUME
Enables access to a directory on the host machine
WORKDIR
Sets where CMD is executed from
8. Dockerfile
# Version 1.0
FROM fedora
MAINTAINER scollier <scollier@redhat.com>
RUN yum -y update
RUN yum -y install mongodb-server
# Create a directory here for the MongoDB data store.
RUN mkdir -p /data/db
RUN sed -i 's/dbpath =/var/lib/mongodb/dbpath =/data/db/' /etc/mongodb.conf
VOLUME ["/data/db"]
EXPOSE 27017
ENTRYPOINT ["/usr/bin/mongod"]
10. Dockerfiles
Time to Build, how can they be called?
Github
# docker build git://github.com/scollier/dockerfilesrabbitmq.git
Locally
When in current directory
# docker build .
When located somewhere else
# docker build - < /path/to/Dockerfile
Trusted Builds
Link between index.docker.io and your github account
Code triggers a build
12. Fedora Project
Where can you get some example Fedora
dockerfiles?
GitHub
https://github.com/scollier/Fedora-Dockerfiles
Fedora Hosted
https://git.fedorahosted.org/cgit/dockerfiles.git/
# yum -y install fedora-dockerfiles
13. Fedora Project, cont
What's there?
nginx, apache, couchdb, firefox, memcached, mongodb,
mysql, postgres, rabbitmq, ssh, wordpress, more to
come!
Each example contains Dockerfile
How to run
How to test