Fedora Dockerfiles

17
a primer... Scott Collier Presented by System Engineer, Red Hat Creative Common Attribution License Dockerfiles

Transcript of Fedora Dockerfiles

Page 1: Fedora Dockerfiles

a primer...

Scott CollierPresented by

System Engineer, Red Hat

Creative Common Attribution License

Dockerfiles

Page 2: Fedora Dockerfiles

Today's Topics

1. Whoami

2. Introduction

3. Dockerfiles

4. Fedora Project

5. Where to go from here?

6. Demo

Page 3: Fedora Dockerfiles

3

Introduction

Page 4: Fedora Dockerfiles

Do you have to have them?

No.

What are they?

Dockerfiles

Page 5: Fedora Dockerfiles

Single Process Container

Multi-Process Container

How?

Host Container

Official / Trusted / Non-Trusted Images

Containers / Images

Page 6: Fedora Dockerfiles

6

Dockerfiles

Page 7: Fedora 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

Page 8: Fedora Dockerfiles

# Version 1.0

FROM fedora

MAINTAINER scollier <[email protected]>

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

Page 9: Fedora Dockerfiles

Building

docker build --help

--no-cache=true

Don't use cache

-q=true

Be quite!

-rm

Remove intermediate containers after build

-t

Tag!

Dockerfiles

Page 10: Fedora 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

Page 11: Fedora Dockerfiles

11

Fedora Project

Page 12: Fedora Dockerfiles

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

Page 13: Fedora Dockerfiles

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

Page 14: Fedora Dockerfiles

14

Demo

Page 15: Fedora Dockerfiles

Start from scratch!

Explore some Dockerfiles

Local Build of Single Process Container

Remote Build of Multi-Process Container

Demo

Page 16: Fedora Dockerfiles

colliernotes.com

@collier_s

Stay in Touch

Page 17: Fedora Dockerfiles

17

Questions?

Creative Common Attribution License