Fedora Dockerfiles

Post on 19-Jul-2015

226 views 0 download

Tags:

Transcript of Fedora Dockerfiles

a primer...

Scott CollierPresented by

System Engineer, Red Hat

Creative Common Attribution License

Dockerfiles

Today's Topics

1. Whoami

2. Introduction

3. Dockerfiles

4. Fedora Project

5. Where to go from here?

6. Demo

3

Introduction

Do you have to have them?

No.

What are they?

Dockerfiles

Single Process Container

Multi-Process Container

How?

Host Container

Official / Trusted / Non-Trusted Images

Containers / Images

6

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

Dockerfiles

# 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"]

Dockerfile

Building

docker build --help

--no-cache=true

Don't use cache

-q=true

Be quite!

-rm

Remove intermediate containers after build

-t

Tag!

Dockerfiles

Time to Build, how can they be called?

Github

# docker build git://github.com/scollier/dockerfiles-rabbitmq.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

Dockerfiles

11

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

Fedora Project

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

Fedora Project, cont

14

Demo

Start from scratch!

Explore some Dockerfiles

Local Build of Single Process Container

Remote Build of Multi-Process Container

Demo

colliernotes.com

@collier_s

Stay in Touch

17

Questions?

Creative Common Attribution License