Files
docker-docs/engine/userguide/dockerimages/index.html
2017-04-14 10:39:00 -07:00

2870 lines
119 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="description" content="How to work with Docker images.">
<meta name="keywords" content="[documentation, docs, the docker guide, docker guide, docker, docker platform, virtualization framework, docker.io, Docker images, Docker image, image management, Docker repos, Docker repositories, docker, docker tag, docker tags, Docker Hub, collaboration]">
<title>Build your own images </title>
<link rel="shortcut icon" href="https://docs.docker.com/images/favicon.png" type="image/x-icon">
<link rel="stylesheet" href="/dist/assets/css/bootstrap-custom.css"/>
<link rel="stylesheet" href="/dist/assets/css/app.css" />
<link rel="stylesheet" href="/dist/assets/css/bootstrap-custom.css"/>
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/animate.css/3.2.6/animate.min.css">
<link rel="stylesheet" href="../../../css/custom.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="../../../dist/assets/js/modernizr.js"></script>
</head>
<body>
<div class="off-canvas-wrap" data-offcanvas>
<div class="inner-wrap">
<a class="left-off-canvas-toggle" href="#" >
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="35px" height="35px" viewBox="0 0 35 35" enable-background="new 0 0 35 35" xml:space="preserve">
<path fill="#3597D4" d="M30.583,9.328c0,0.752-0.539,1.362-1.203,1.362H5.113c-0.664,0-1.203-0.61-1.203-1.362l0,0
c0-0.752,0.539-1.362,1.203-1.362H29.38C30.045,7.966,30.583,8.576,30.583,9.328L30.583,9.328z"/>
<path fill="#3597D4" d="M30.583,17.09c0,0.752-0.539,1.362-1.203,1.362H5.113c-0.664,0-1.203-0.61-1.203-1.362l0,0
c0-0.752,0.539-1.362,1.203-1.362H29.38C30.045,15.728,30.583,16.338,30.583,17.09L30.583,17.09z"/>
<path fill="#3597D4" d="M30.583,24.387c0,0.752-0.539,1.362-1.203,1.362H5.113c-0.664,0-1.203-0.61-1.203-1.362l0,0
c0-0.752,0.539-1.362,1.203-1.362H29.38C30.045,23.025,30.583,23.635,30.583,24.387L30.583,24.387z"/>
</svg>
</a>
<a class="button secondary small get-started-cta">Get Started</a>
<header class="main-header">
<div class="row">
<div class="large-3 columns">
<a href="../../../"><img class="logo" src="../../../dist/assets/images/logo.png"></a>
</div>
<div class="large-9 columns">
<ul class="nav-global">
<li><a href="https://www.docker.com/support">Support</a></li>
<li><a href="https://training.docker.com/">Training</a></li>
<li><a href="https://docs.docker.com/">Docs</a></li>
<li><a href="http://blog.docker.com/">Blog</a></li>
<li><a href="https://hub.docker.com/">Docker Hub</a></li>
<li><a class="button" href="../../../mac/started/">Get Started</a></li>
</ul>
<ul class="nav-main">
<li><a href="https://www.docker.com/products">Products</a>
<ul>
<li><a href="https://www.docker.com/pricing">Pricing</a></li>
<li><a href="https://www.docker.com/whatisdocker">What is Docker?</a></li>
</ul>
</li>
<li><a href="https://www.docker.com/customers">Customers</a></li>
<li><a href="https://www.docker.com/community">Community</a>
<ul>
<li><a href="https://www.docker.com/community/meetups">Meetups</a></li>
<li><a href="https://www.docker.com/community/events">Events</a></li>
<li><a href="https://forums.docker.com">Forums</a></li>
<li><a href="http://www.scoop.it/t/docker-by-docker">Community News</a></li>
</ul>
</li>
<li><a href="https://www.docker.com/partners">Partners</a>
<ul>
<li><a href="https://www.docker.com/partners/partner-programs">Partner Programs</a></li>
</ul>
</li>
<li><a href="https://www.docker.com/company">Company</a>
<ul>
<li><a href="https://www.docker.com/news-and-press">News &amp; Press</a></li>
<li><a href="https://www.docker.com/work-docker">Work at Docker</a></li>
<li><a href="https://www.docker.com/company/management">Management</a></li>
<li><a href="https://www.docker.com/company/contact">Contact</a></li>
</ul>
</li>
<li><a href="https://www.docker.com/open-source">Open Source</a>
<ul>
<li><a href="https://www.docker.com/contribute">Contribute</a></li>
</ul>
</li>
</ul>
</div>
</div>
</header>
<aside class="left-off-canvas-menu">
<ul class="off-canvas-list">
<li class="has-submenu"><a href="#">Products</a>
<ul class="left-submenu">
<li class="back"><a href="#">Back</a></li>
<li><a href="#">Pricing</a></li>
<li><a href="#">What Is Docker</a></li>
<li><a href="#">Products</a></li>
<li><a href="#">Docker Engine</a></li>
<li><a href="#">Docker Hub</a></li>
<li><a href="#">Docker Registry</a></li>
<li><a href="#">Docker Machine</a></li>
<li><a href="#">Docker Swarm</a></li>
<li><a href="#">Docker Compose</a></li>
<li><a href="#">Kitematic</a></li>
</ul>
</li>
<li><a href="#">Customers</a></li>
<li class="has-submenu"><a href="#">Community</a>
<ul class="left-submenu">
<li class="back"><a href="#">Back</a></li>
<li><a href="#">Community</a></li>
<li><a href="#">Meetups</a></li>
<li><a href="https://www.docker.com/community/events">Events</a></li>
<li><a href="#">Forum</a></li>
<li><a href="#">Scoop.it</a></li>
</ul>
</li>
<li class="has-submenu"><a href="#">Partners</a>
<ul class="left-submenu">
<li class="back"><a href="#">Back</a></li>
<li><a href="#">Partners</a></li>
<li><a href="https://www.docker.com/partners/partner-programs">Partners Programs</a></li>
</ul>
</li>
<li><a href="#">Company</a></li>
<li class="has-submenu"><a href="#">Open Source</a>
<ul class="left-submenu">
<li class="back"><a href="#">Back</a></li>
<li><a href="#">Open Source</a></li>
<li><a href="#">Contribute</a></li>
<li><a href="#">Governance</a></li>
</ul>
</li>
</ul>
<ul class="nav-global-off-canvas">
<li><a href="#">Support</a></li>
<li><a href="#">Training</a></li>
<li><a href="#">Docs</a></li>
<li><a href="#">Blog</a></li>
<li><a href="#">Sign in</a></li>
<li><a href="#">Sign up</a></li>
</ul>
</aside>
<a class="exit-off-canvas"></a>
<div id="docs" class="row">
<div class="large-3 columns">
<section id="multiple" data-accordion-group>
<section data-accordion>
<article data-accordion>
<button data-control> Install</button>
<div data-content>
<article data-accordion>
<button data-control> Docker Engine</button>
<div data-content>
<a data-link href="../../../engine/installation/mac/" class=""> Installation on Mac OS X</a>
<a data-link href="../../../engine/installation/windows/" class=""> Installation on Windows</a>
<article data-accordion>
<button data-control> Linux</button>
<div data-content>
<a data-link href="../../../engine/installation/ubuntulinux/" class=""> Installation on Ubuntu </a>
<a data-link href="../../../engine/installation/rhel/" class=""> Installation on Red Hat Enterprise Linux</a>
<a data-link href="../../../engine/installation/centos/" class=""> Installation on CentOS</a>
<a data-link href="../../../engine/installation/fedora/" class=""> Installation on Fedora</a>
<a data-link href="../../../engine/installation/debian/" class=""> Installation on Debian</a>
<a data-link href="../../../engine/installation/archlinux/" class=""> Installation on Arch Linux</a>
<a data-link href="../../../engine/installation/cruxlinux/" class=""> Installation on CRUX Linux</a>
<a data-link href="../../../engine/installation/frugalware/" class=""> Installation on FrugalWare</a>
<a data-link href="../../../engine/installation/gentoolinux/" class=""> Installation on Gentoo</a>
<a data-link href="../../../engine/installation/oracle/" class=""> Installation on Oracle Linux</a>
<a data-link href="../../../engine/installation/SUSE/" class=""> Installation on openSUSE and SUSE Linux Enterprise</a>
</div>
</article>
<article data-accordion>
<button data-control> Cloud</button>
<div data-content>
<a data-link href="../../../engine/installation/amazon/" class=""> Amazon EC2 Installation</a>
<a data-link href="../../../engine/installation/google/" class=""> Installation on Google Cloud Platform</a>
<a data-link href="../../../engine/installation/softlayer/" class=""> Installation on IBM SoftLayer </a>
<a data-link href="../../../engine/installation/azure/" class=""> Installation on Microsoft Azure platform</a>
<a data-link href="../../../engine/installation/rackspace/" class=""> Installation on Rackspace Cloud</a>
<a data-link href="../../../engine/installation/joyent/" class=""> Joyent Triton Elastic Container Service</a>
</div>
</article>
<a data-link href="../../../engine/installation/binaries/" class=""> Installation from binaries</a>
</div>
</article>
<a data-link href="../../../kitematic/" class=""> Kitematic</a>
<a data-link href="../../../machine/install-machine/" class=""> Docker Machine</a>
<a data-link href="../../../compose/install/" class=""> Docker Compose</a>
<a data-link href="../../../swarm/install-w-machine/" class=""> Docker Swarm</a>
</div>
</article>
</section>
<section data-accordion>
<article data-accordion>
<button data-control> Docker Fundamentals</button>
<div data-content>
<a data-link href="../../../engine/userguide/basics/" class=""> Quickstart containers</a>
<a data-link href="../../../engine/userguide/" class=""> The Docker user guide</a>
<article data-accordion>
<button data-control> Work with Docker Images</button>
<div data-content>
<a data-link href="../../../engine/articles/dockerfile_best-practices/" class=""> Best practices for writing Dockerfiles</a>
<a data-link href="../../../engine/articles/baseimages/" class=""> Create a base image</a>
</div>
</article>
<article data-accordion>
<button data-control> Work with Docker Containers</button>
<div data-content>
<a data-link href="../../../engine/userguide/dockerizing/" class=""> Hello world in a container</a>
<a data-link href="../../../engine/userguide/usingdocker/" class=""> Run a simple application</a>
<a data-link href="../../../engine/userguide/dockerimages/" class=" active"> Build your own images</a>
<a data-link href="../../../engine/userguide/networkingcontainers/" class=""> Networking containers</a>
<a data-link href="../../../engine/userguide/dockervolumes/" class=""> Manage data in containers</a>
<a data-link href="../../../engine/userguide/dockerrepos/" class=""> Store images on Docker Hub</a>
</div>
</article>
<article data-accordion>
<button data-control> Docker on Windows &amp; OSX</button>
<div data-content>
<a data-link href="../../../engine/articles/dsc/" class=""> PowerShell DSC Usage</a>
</div>
</article>
<article data-accordion>
<button data-control> Use the Kitematic GUI</button>
<div data-content>
<a data-link href="../../../kitematic/userguide/" class=""> Kitematic User Guide: Intro &amp; Overview</a>
<a data-link href="../../../kitematic/nginx-web-server/" class=""> Set up an Nginx web server</a>
<a data-link href="../../../kitematic/minecraft-server/" class=""> Set up a Minecraft Server</a>
<a data-link href="../../../kitematic/rethinkdb-dev-database/" class=""> Creating a Local RethinkDB Database for Development</a>
<a data-link href="../../../kitematic/faq/" class=""> Frequently Asked Questions</a>
<a data-link href="../../../kitematic/known-issues/" class=""> Known Issues</a>
</div>
</article>
</div>
</article>
</section>
<section data-accordion>
<article data-accordion>
<button data-control> Use Docker</button>
<div data-content>
<a data-link href="../../../engine/misc/" class=""> About Docker</a>
<a data-link href="../../../engine/userguide/labels-custom-metadata/" class=""> Apply custom metadata</a>
<a data-link href="../../../engine/misc/deprecated/" class=""> Docker Deprecated Features</a>
<a data-link href="/engine/introduction/understanding-docker/" class=""> Understand the architecture</a>
<article data-accordion>
<button data-control> Provision &amp; set up Docker hosts</button>
<div data-content>
<a data-link href="../../../machine/" class=""> Overview of Docker Machine</a>
<a data-link href="../../../machine/get-started/" class=""> Get started with Docker Machine and a local VM</a>
<a data-link href="../../../machine/get-started-cloud/" class=""> Using Docker Machine with a cloud provider</a>
<a data-link href="../../../machine/migrate-to-machine/" class=""> Migrate from Boot2Docker to Docker Machine</a>
</div>
</article>
<article data-accordion>
<button data-control> Create multi-container applications</button>
<div data-content>
<a data-link href="../../../compose/" class=""> Overview of Docker Compose</a>
<a data-link href="../../../compose/production/" class=""> Using Compose in production</a>
<a data-link href="../../../compose/extends/" class=""> Extending services in Compose</a>
<a data-link href="../../../compose/gettingstarted/" class=""> Getting Started</a>
<a data-link href="../../../compose/django/" class=""> Quickstart Guide: Compose and Django</a>
<a data-link href="../../../compose/rails/" class=""> Quickstart Guide: Compose and Rails</a>
<a data-link href="../../../compose/networking/" class=""> Networking in Compose</a>
<a data-link href="../../../compose/wordpress/" class=""> Quickstart Guide: Compose and WordPress</a>
<a data-link href="../../../compose/completion/" class=""> Command-line Completion</a>
</div>
</article>
<article data-accordion>
<button data-control> Cluster Docker containers</button>
<div data-content>
<a data-link href="../../../swarm/" class=""> Docker Swarm</a>
<a data-link href="../../../swarm/install-manual/" class=""> Create a swarm for development</a>
<a data-link href="../../../swarm/multi-manager-setup/" class=""> High availability in Docker Swarm</a>
<a data-link href="../../../swarm/networking/" class=""> Docker Swarm Networking</a>
<a data-link href="../../../swarm/discovery/" class=""> Docker Swarm discovery</a>
<a data-link href="../../../swarm/scheduler/filter/" class=""> Docker Swarm filters</a>
<a data-link href="../../../swarm/scheduler/strategy/" class=""> Docker Swarm strategies</a>
</div>
</article>
<article data-accordion>
<button data-control> Administrate Docker</button>
<div data-content>
<a data-link href="../../../engine/articles/host_integration/" class=""> Automatically start containers</a>
<a data-link href="../../../engine/articles/security/" class=""> Docker security</a>
<a data-link href="../../../engine/articles/configuring/" class=""> Configuring and running Docker</a>
<a data-link href="../../../engine/articles/runmetrics/" class=""> Runtime metrics</a>
<a data-link href="../../../engine/articles/https/" class=""> Protect the Docker daemon socket</a>
<a data-link href="../../../engine/articles/ambassador_pattern_linking/" class=""> Link via an ambassador container</a>
<a data-link href="../../../engine/articles/systemd/" class=""> Control and configure Docker with systemd</a>
<article data-accordion>
<button data-control> Logging</button>
<div data-content>
<a data-link href="../../../engine/reference/logging/overview/" class=""> Configuring Logging Drivers</a>
<a data-link href="../../../engine/reference/logging/awslogs/" class=""> Amazon CloudWatch Logs logging driver</a>
<a data-link href="../../../engine/reference/logging/log_tags/" class=""> Log tags for logging driver</a>
<a data-link href="../../../engine/reference/logging/fluentd/" class=""> Fluentd logging driver</a>
<a data-link href="../../../engine/reference/logging/splunk/" class=""> Splunk logging driver</a>
<a data-link href="../../../engine/reference/logging/journald/" class=""> journald logging driver</a>
</div>
</article>
<article data-accordion>
<button data-control> Applications and Services</button>
<div data-content>
<a data-link href="../../../engine/examples/running_riak_service/" class=""> Dockerizing a Riak service</a>
<a data-link href="../../../engine/examples/running_ssh_service/" class=""> Dockerizing an SSH service</a>
</div>
</article>
<article data-accordion>
<button data-control> Integrate with Third-party Tools</button>
<div data-content>
<a data-link href="../../../engine/articles/cfengine_process_management/" class=""> Process management with CFEngine</a>
<a data-link href="../../../engine/articles/chef/" class=""> Using Chef</a>
<a data-link href="../../../engine/articles/puppet/" class=""> Using Puppet</a>
<a data-link href="../../../engine/articles/using_supervisord/" class=""> Using Supervisor with Docker</a>
</div>
</article>
</div>
</article>
<article data-accordion>
<button data-control> Docker storage drivers</button>
<div data-content>
<a data-link href="../../../engine/userguide/storagedriver/imagesandcontainers/" class=""> Understand images, containers, and storage drivers</a>
<a data-link href="../../../engine/userguide/storagedriver/selectadriver/" class=""> Select a storage driver</a>
<a data-link href="../../../engine/userguide/storagedriver/aufs-driver/" class=""> AUFS storage driver in practice</a>
<a data-link href="../../../engine/userguide/storagedriver/btrfs-driver/" class=""> BTRFS storage in practice</a>
<a data-link href="../../../engine/userguide/storagedriver/device-mapper-driver/" class=""> Device mapper storage in practice</a>
<a data-link href="../../../engine/userguide/storagedriver/overlayfs-driver/" class=""> OverlayFS storage in practice</a>
<a data-link href="../../../engine/userguide/storagedriver/zfs-driver/" class=""> ZFS storage in practice</a>
</div>
</article>
<article data-accordion>
<button data-control> Network configuration</button>
<div data-content>
<a data-link href="../../../engine/userguide/networking/dockernetworks/" class=""> Docker container networking</a>
<a data-link href="../../../engine/userguide/networking/work-with-networks/" class=""> Work with network commands</a>
<a data-link href="../../../engine/userguide/networking/get-started-overlay/" class=""> Get started with multi-host networking</a>
<article data-accordion>
<button data-control> Default bridge network</button>
<div data-content>
<a data-link href="../../../engine/userguide/networking/default_network/dockerlinks/" class=""> Legacy container links</a>
<a data-link href="../../../engine/userguide/networking/default_network/binding/" class=""> Bind container ports to the host</a>
<a data-link href="../../../engine/userguide/networking/default_network/build-bridges/" class=""> Build your own bridge</a>
<a data-link href="../../../engine/userguide/networking/default_network/configure-dns/" class=""> Configure container DNS</a>
<a data-link href="../../../engine/userguide/networking/default_network/custom-docker0/" class=""> Customize the docker0 bridge</a>
<a data-link href="../../../engine/userguide/networking/default_network/container-communication/" class=""> Understand container communication</a>
<a data-link href="../../../engine/userguide/networking/default_network/ipv6/" class=""> IPv6 with Docker</a>
</div>
</article>
</div>
</article>
<article data-accordion>
<button data-control> Applied Docker</button>
<div data-content>
<a data-link href="../../../engine/examples/mongodb/" class=""> Dockerizing MongoDB</a>
<a data-link href="../../../engine/examples/postgresql_service/" class=""> Dockerizing PostgreSQL</a>
<a data-link href="../../../engine/examples/couchdb_data_volumes/" class=""> Dockerizing a CouchDB service</a>
<a data-link href="../../../engine/examples/nodejs_web_app/" class=""> Dockerizing a Node.js web app</a>
<a data-link href="../../../engine/examples/running_redis_service/" class=""> Dockerizing a Redis service</a>
<a data-link href="../../../engine/examples/apt-cacher-ng/" class=""> Dockerizing an apt-cacher-ng service</a>
</div>
</article>
</div>
</article>
</section>
<section data-accordion>
<article data-accordion>
<button data-control> Manage image repositories</button>
<div data-content>
<a data-link href="../../../engine/userguide/image_management/" class=""> Image management</a>
<article data-accordion>
<button data-control> Docker Hub</button>
<div data-content>
<a data-link href="../../../docker-hub/" class=""> Introducing Docker Hub</a>
<a data-link href="../../../docker-hub/accounts/" class=""> Your Docker Hub account</a>
<a data-link href="../../../docker-hub/repos/" class=""> Repositories on Docker Hub</a>
<a data-link href="../../../docker-hub/builds/" class=""> Automated Builds on Docker Hub</a>
<a data-link href="../../../docker-hub/github/" class=""> Automated Builds from GitHub</a>
<a data-link href="../../../docker-hub/bitbucket/" class=""> Automated Builds with Bitbucket</a>
<a data-link href="../../../docker-hub/orgs/" class=""> Teams &amp; Organizations</a>
<a data-link href="../../../docker-hub/official_repos/" class=""> Official Repositories on Docker Hub</a>
</div>
</article>
<article data-accordion>
<button data-control> Docker Trusted Registry</button>
<div data-content>
<a data-link href="../../../docker-trusted-registry/" class=""> Overview</a>
<article data-accordion>
<button data-control> Trusted Registry installation overview</button>
<div data-content>
<a data-link href="../../../docker-trusted-registry/install/dtr-ami-byol-launch/" class=""> Install Docker Subscription for AWS (BYOL))</a>
<a data-link href="../../../docker-trusted-registry/install/engine-ami-launch/" class=""> Install Docker Engine for AWS AMI (BDS)</a>
<a data-link href="../../../docker-trusted-registry/install/dtr-ami-bds-launch/" class=""> Install Trusted Registry for AWS AMI (BDS)</a>
<a data-link href="../../../docker-trusted-registry/install/install-csengine/" class=""> Manually Install the CS Docker Engine</a>
<a data-link href="../../../docker-trusted-registry/install/install-dtr/" class=""> Manually install Trusted Registry</a>
<a data-link href="../../../docker-trusted-registry/install/upgrade/" class=""> Upgrade Trusted Registry and CS Engine</a>
</div>
</article>
<a data-link href="../../../docker-trusted-registry/quick-start/" class=""> Quick-start: Basic Workflow</a>
<a data-link href="../../../docker-trusted-registry/userguide/" class=""> User guide</a>
<a data-link href="../../../docker-trusted-registry/adminguide/" class=""> Admin guide</a>
<a data-link href="../../../docker-trusted-registry/configuration/" class=""> Configuration options</a>
<a data-link href="../../../docker-trusted-registry/license/" class=""> Trusted Registry License</a>
<article data-accordion>
<button data-control> DTR APIs</button>
<div data-content>
<a data-link href="../../../docker-trusted-registry/api/" class=""> Docker Trusted Registry Accounts &amp; Repos API: Intro &amp; Overview</a>
<a data-link href="../../../docker-trusted-registry/api/dtr_1_3_accounts/" class=""> Docker Trusted Registry Accounts API</a>
<a data-link href="../../../docker-trusted-registry/api/dtr_1_3_teams/" class=""> Docker Trusted Registry User and Org API</a>
<a data-link href="../../../docker-trusted-registry/api/dtr_1_3_repositories/" class=""> Docker Trusted Registry Repository API</a>
<a data-link href="../../../docker-trusted-registry/api/dtr_1_3_user_repo_access/" class=""> Docker Trusted Registry User Repository API</a>
<a data-link href="../../../docker-trusted-registry/api/dtr_1_3_team_repo_access/" class=""> Docker Trusted Registry Org Repository API</a>
<a data-link href="../../../docker-trusted-registry/api/dtr_1_3_team_repo_namespace_access/" class=""> Docker Trusted Registry Org Namespace API</a>
</div>
</article>
<a data-link href="../../../docker-trusted-registry/support/" class=""> Support</a>
<a data-link href="../../../docker-trusted-registry/release-notes/" class=""> Release notes</a>
<a data-link href="../../../docker-trusted-registry/prior-release-notes/" class=""> Prior release notes archive</a>
</div>
</article>
<article data-accordion>
<button data-control> Docker Registry</button>
<div data-content>
<a data-link href="../../../registry/" class=""> Docker Registry</a>
<a data-link href="../../../registry/introduction/" class=""> Understanding the Registry</a>
<a data-link href="../../../registry/deploying/" class=""> Deploying a registry server</a>
<a data-link href="../../../registry/configuration/" class=""> Configuring a registry</a>
<a data-link href="../../../registry/notifications/" class=""> Working with notifications</a>
<a data-link href="../../../registry/help/" class=""> Getting help</a>
</div>
</article>
<article data-accordion>
<button data-control> Use trusted images</button>
<div data-content>
<a data-link href="../../../engine/security/trust/content_trust/" class=""> Content trust in Docker</a>
<a data-link href="../../../engine/security/trust/trust_automation/" class=""> Automation with content trust</a>
<a data-link href="../../../engine/security/trust/trust_key_mng/" class=""> Manage keys for content trust</a>
<a data-link href="../../../engine/security/trust/trust_sandbox/" class=""> Play in a content trust sandbox</a>
</div>
</article>
<a data-link href="../../../engine/articles/certificates/" class=""> Using certificates for repository client verification</a>
<a data-link href="../../../engine/articles/registry_mirror/" class=""> Run a local registry mirror</a>
</div>
</article>
</section>
<section data-accordion>
<article data-accordion>
<button data-control> Extend Docker</button>
<div data-content>
<a data-link href="../../../engine/extend/plugins_network/" class=""> Docker network driver plugins</a>
<a data-link href="../../../engine/extend/plugins/" class=""> Extending Docker with plugins</a>
<a data-link href="../../../engine/extend/plugins_volume/" class=""> Volume plugins</a>
<a data-link href="../../../engine/extend/plugin_api/" class=""> Plugins API</a>
</div>
</article>
</section>
<section data-accordion>
<article data-accordion>
<button data-control> Command and API references</button>
<div data-content>
<a data-link href="../../../engine/reference/run/" class=""> Docker run reference</a>
<a data-link href="../../../engine/reference/builder/" class=""> Dockerfile reference</a>
<a data-link href="../../../engine/reference/api/remote_api_client_libraries/" class=""> Remote API client libraries</a>
<article data-accordion>
<button data-control> Using the command line</button>
<div data-content>
<a data-link href="../../../engine/reference/commandline/cli/" class=""> Use the Docker command line</a>
<a data-link href="../../../engine/reference/commandline/daemon/" class=""> daemon</a>
<a data-link href="../../../engine/reference/commandline/attach/" class=""> attach</a>
<a data-link href="../../../engine/reference/commandline/build/" class=""> build</a>
<a data-link href="../../../engine/reference/commandline/commit/" class=""> commit</a>
<a data-link href="../../../engine/reference/commandline/cp/" class=""> cp</a>
<a data-link href="../../../engine/reference/commandline/create/" class=""> create</a>
<a data-link href="../../../engine/reference/commandline/diff/" class=""> diff</a>
<a data-link href="../../../engine/reference/commandline/events/" class=""> events</a>
<a data-link href="../../../engine/reference/commandline/exec/" class=""> exec</a>
<a data-link href="../../../engine/reference/commandline/export/" class=""> export</a>
<a data-link href="../../../engine/reference/commandline/history/" class=""> history</a>
<a data-link href="../../../engine/reference/commandline/images/" class=""> images</a>
<a data-link href="../../../engine/reference/commandline/import/" class=""> import</a>
<a data-link href="../../../engine/reference/commandline/info/" class=""> info</a>
<a data-link href="../../../engine/reference/commandline/inspect/" class=""> inspect</a>
<a data-link href="../../../engine/reference/commandline/kill/" class=""> kill</a>
<a data-link href="../../../engine/reference/commandline/load/" class=""> load</a>
<a data-link href="../../../engine/reference/commandline/login/" class=""> login</a>
<a data-link href="../../../engine/reference/commandline/logout/" class=""> logout</a>
<a data-link href="../../../engine/reference/commandline/logs/" class=""> logs</a>
<a data-link href="../../../engine/reference/commandline/network_connect/" class=""> network connect</a>
<a data-link href="../../../engine/reference/commandline/network_create/" class=""> network create</a>
<a data-link href="../../../engine/reference/commandline/network_disconnect/" class=""> network disconnect</a>
<a data-link href="../../../engine/reference/commandline/network_inspect/" class=""> network inspect</a>
<a data-link href="../../../engine/reference/commandline/network_ls/" class=""> network ls</a>
<a data-link href="../../../engine/reference/commandline/network_rm/" class=""> network rm</a>
<a data-link href="../../../engine/reference/commandline/pause/" class=""> pause</a>
<a data-link href="../../../engine/reference/commandline/port/" class=""> port</a>
<a data-link href="../../../engine/reference/commandline/ps/" class=""> ps</a>
<a data-link href="../../../engine/reference/commandline/pull/" class=""> pull</a>
<a data-link href="../../../engine/reference/commandline/push/" class=""> push</a>
<a data-link href="../../../engine/reference/commandline/rename/" class=""> rename</a>
<a data-link href="../../../engine/reference/commandline/restart/" class=""> restart</a>
<a data-link href="../../../engine/reference/commandline/rm/" class=""> rm</a>
<a data-link href="../../../engine/reference/commandline/rmi/" class=""> rmi</a>
<a data-link href="../../../engine/reference/commandline/run/" class=""> run</a>
<a data-link href="../../../engine/reference/commandline/save/" class=""> save</a>
<a data-link href="../../../engine/reference/commandline/search/" class=""> search</a>
<a data-link href="../../../engine/reference/commandline/start/" class=""> start</a>
<a data-link href="../../../engine/reference/commandline/stats/" class=""> stats</a>
<a data-link href="../../../engine/reference/commandline/stop/" class=""> stop</a>
<a data-link href="../../../engine/reference/commandline/tag/" class=""> tag</a>
<a data-link href="../../../engine/reference/commandline/top/" class=""> top</a>
<a data-link href="../../../engine/reference/commandline/unpause/" class=""> unpause</a>
<a data-link href="../../../engine/reference/commandline/version/" class=""> version</a>
<a data-link href="../../../engine/reference/commandline/volume_create/" class=""> volume create</a>
<a data-link href="../../../engine/reference/commandline/volume_inspect/" class=""> volume inspect</a>
<a data-link href="../../../engine/reference/commandline/volume_ls/" class=""> volume ls</a>
<a data-link href="../../../engine/reference/commandline/volume_rm/" class=""> volume rm</a>
<a data-link href="../../../engine/reference/commandline/wait/" class=""> wait</a>
</div>
</article>
<a data-link href="../../../engine/reference/api/docker_io_accounts_api/" class=""> docker.io accounts API</a>
<article data-accordion>
<button data-control> Docker Remote API</button>
<div data-content>
<a data-link href="../../../engine/reference/api/docker_remote_api/" class=""> Remote API</a>
<a data-link href="../../../engine/reference/api/docker_remote_api_v1.21/" class=""> Remote API v1.21</a>
<a data-link href="../../../engine/reference/api/docker_remote_api_v1.20/" class=""> Remote API v1.20</a>
<a data-link href="../../../engine/reference/api/docker_remote_api_v1.19/" class=""> Remote API v1.19</a>
<a data-link href="../../../engine/reference/api/docker_remote_api_v1.18/" class=""> Remote API v1.18</a>
<a data-link href="../../../engine/reference/api/docker_remote_api_v1.17/" class=""> Remote API v1.17</a>
<a data-link href="../../../engine/reference/api/docker_remote_api_v1.16/" class=""> Remote API v1.16</a>
<a data-link href="../../../engine/reference/api/docker_remote_api_v1.15/" class=""> Remote API v1.15</a>
<a data-link href="../../../engine/reference/api/docker_remote_api_v1.14/" class=""> Remote API v1.14</a>
<a data-link href="../../../engine/reference/api/docker-io_api/" class=""> Docker Hub API</a>
</div>
</article>
<article data-accordion>
<button data-control> Docker Hub</button>
<div data-content>
<a data-link href="../../../engine/reference/api/hub_registry_spec/" class=""> The Docker Hub and the Registry v1</a>
</div>
</article>
<a data-link href="../../../docker-trusted-registry/api/dtr_api/" class=""> Docker Trusted Registry</a>
<article data-accordion>
<button data-control> Docker Compose Reference</button>
<div data-content>
<article data-accordion>
<button data-control> Compose CLI reference</button>
<div data-content>
<a data-link href="../../../compose/reference/overview/" class=""> Introduction to the CLI</a>
<a data-link href="../../../compose/reference/docker-compose/" class=""> docker-compose</a>
<a data-link href="../../../compose/reference/build/" class=""> build</a>
<a data-link href="../../../compose/reference/help/" class=""> help</a>
<a data-link href="../../../compose/reference/kill/" class=""> kill</a>
<a data-link href="../../../compose/reference/logs/" class=""> logs</a>
<a data-link href="../../../compose/reference/pause/" class=""> pause</a>
<a data-link href="../../../compose/reference/port/" class=""> port</a>
<a data-link href="../../../compose/reference/ps/" class=""> ps</a>
<a data-link href="../../../compose/reference/pull/" class=""> pull</a>
<a data-link href="../../../compose/reference/restart/" class=""> restart</a>
<a data-link href="../../../compose/reference/rm/" class=""> rm</a>
<a data-link href="../../../compose/reference/run/" class=""> run</a>
<a data-link href="../../../compose/reference/scale/" class=""> scale</a>
<a data-link href="../../../compose/reference/start/" class=""> start</a>
<a data-link href="../../../compose/reference/stop/" class=""> stop</a>
<a data-link href="../../../compose/reference/unpause/" class=""> unpause</a>
<a data-link href="../../../compose/reference/up/" class=""> up</a>
</div>
</article>
<a data-link href="../../../compose/compose-file/" class=""> Compose file reference</a>
<a data-link href="../../../compose/env/" class=""> Compose environment variables reference</a>
</div>
</article>
<article data-accordion>
<button data-control> Docker Machine Reference</button>
<div data-content>
<article data-accordion>
<button data-control> Drivers</button>
<div data-content>
<a data-link href="../../../machine/drivers/os-base/" class=""> Driver options and operating system defaults</a>
<a data-link href="../../../machine/drivers/aws/" class=""> Amazon Web Services</a>
<a data-link href="../../../machine/drivers/digital-ocean/" class=""> Digital Ocean</a>
<a data-link href="../../../machine/drivers/generic/" class=""> Generic</a>
<a data-link href="../../../machine/drivers/gce/" class=""> Google Compute Engine</a>
<a data-link href="../../../machine/drivers/soft-layer/" class=""> IBM Softlayer</a>
<a data-link href="../../../machine/drivers/azure/" class=""> Microsoft Azure</a>
<a data-link href="../../../machine/drivers/hyper-v/" class=""> Microsoft Hyper-V</a>
<a data-link href="../../../machine/drivers/openstack/" class=""> OpenStack</a>
<a data-link href="../../../machine/drivers/virtualbox/" class=""> Oracle VirtualBox</a>
<a data-link href="../../../machine/drivers/rackspace/" class=""> Rackspace</a>
<a data-link href="../../../machine/drivers/vm-fusion/" class=""> VMware Fusion</a>
<a data-link href="../../../machine/drivers/vm-cloud/" class=""> VMware vCloud Air</a>
<a data-link href="../../../machine/drivers/vsphere/" class=""> VMware vSphere</a>
<a data-link href="../../../machine/drivers/exoscale/" class=""> exoscale</a>
</div>
</article>
<article data-accordion>
<button data-control> Subcommands</button>
<div data-content>
<a data-link href="../../../machine/reference/active/" class=""> active</a>
<a data-link href="../../../machine/reference/config/" class=""> config</a>
<a data-link href="../../../machine/reference/create/" class=""> create</a>
<a data-link href="../../../machine/reference/env/" class=""> env</a>
<a data-link href="../../../machine/reference/help/" class=""> help</a>
<a data-link href="../../../machine/reference/inspect/" class=""> inspect</a>
<a data-link href="../../../machine/reference/ip/" class=""> ip</a>
<a data-link href="../../../machine/reference/kill/" class=""> kill</a>
<a data-link href="../../../machine/reference/ls/" class=""> ls</a>
<a data-link href="../../../machine/reference/regenerate-certs/" class=""> regenerate-certs</a>
<a data-link href="../../../machine/reference/restart/" class=""> restart</a>
<a data-link href="../../../machine/reference/rm/" class=""> rm</a>
<a data-link href="../../../machine/reference/scp/" class=""> scp</a>
<a data-link href="../../../machine/reference/ssh/" class=""> ssh</a>
<a data-link href="../../../machine/reference/start/" class=""> start</a>
<a data-link href="../../../machine/reference/status/" class=""> status</a>
<a data-link href="../../../machine/reference/stop/" class=""> stop</a>
<a data-link href="../../../machine/reference/upgrade/" class=""> upgrade</a>
<a data-link href="../../../machine/reference/url/" class=""> url</a>
</div>
</article>
</div>
</article>
<article data-accordion>
<button data-control> Docker Swarm Reference</button>
<div data-content>
<a data-link href="../../../swarm/api/swarm-api/" class=""> Docker Swarm API</a>
</div>
</article>
<article data-accordion>
<button data-control> Docker Registry Reference</button>
<div data-content>
<a data-link href="../../../registry/spec/api/" class=""> HTTP API V2</a>
<a data-link href="../../../registry/storagedrivers/" class=""> Storage Drivers</a>
<a data-link href="../../../registry/spec/auth/jwt/" class=""> Token Authentication Implementation</a>
<a data-link href="../../../registry/spec/auth/token/" class=""> Token Authentication Specification</a>
</div>
</article>
</div>
</article>
</section>
<section data-accordion>
<article data-accordion>
<button data-control> Open Source at Docker</button>
<div data-content>
<a data-link href="../../../opensource/code/" class=""> Quickstart contribution</a>
<article data-accordion>
<button data-control> Set up for Engine Development</button>
<div data-content>
<a data-link href="../../../opensource/project/who-written-for/" class=""> README first</a>
<a data-link href="../../../opensource/project/software-required/" class=""> Get the required software</a>
<a data-link href="../../../opensource/project/software-req-win/" class=""> Set up for development on Windows</a>
<a data-link href="../../../opensource/project/set-up-git/" class=""> Configure Git for contributing</a>
<a data-link href="../../../opensource/project/set-up-dev-env/" class=""> Work with a development container</a>
<a data-link href="../../../opensource/project/test-and-docs/" class=""> Run tests and test documentation</a>
</div>
</article>
<article data-accordion>
<button data-control> Contribution workflow</button>
<div data-content>
<a data-link href="../../../opensource/workflow/make-a-contribution/" class=""> Understand how to contribute</a>
<a data-link href="../../../opensource/workflow/find-an-issue/" class=""> Find and claim an issue</a>
<a data-link href="../../../opensource/workflow/work-issue/" class=""> Work on your issue</a>
<a data-link href="../../../opensource/workflow/create-pr/" class=""> Create a pull request (PR)</a>
<a data-link href="../../../opensource/workflow/review-pr/" class=""> Participate in the PR review</a>
<a data-link href="../../../opensource/workflow/advanced-contributing/" class=""> Advanced contributing</a>
<a data-link href="../../../opensource/workflow/coding-style/" class=""> Coding style checklist</a>
</div>
</article>
<article data-accordion>
<button data-control> Other ways to contribute</button>
<div data-content>
<a data-link href="../../../opensource/ways/meetups/" class=""> Organize a Docker Meetup</a>
<a data-link href="../../../opensource/ways/issues/" class=""> Organize our issues</a>
<a data-link href="../../../opensource/ways/community/" class=""> Support the community</a>
<a data-link href="../../../opensource/ways/test/" class=""> Testing contributions</a>
</div>
</article>
<article data-accordion>
<button data-control> Governance</button>
<div data-content>
<a data-link href="../../../opensource/governance/dgab-info/" class=""> Docker Governance Advisory Board</a>
<a data-link href="../../../opensource/governance/board-profiles/" class=""> Board member profiles</a>
<a data-link href="../../../opensource/governance/conduct-code/" class=""> Code of conduct</a>
</div>
</article>
<a data-link href="../../../opensource/FAQ/" class=""> FAQ for contributors</a>
<a data-link href="../../../opensource/get-help/" class=""> Where to chat or get help</a>
<a data-link href="../../../opensource/doc-style/" class=""> Style guide for Docker documentation</a>
</div>
</article>
</section>
<section data-accordion>
<article data-accordion>
<button data-control> About</button>
<div data-content>
<a data-link href="../../../release-notes/" class=""> Docker Release Notes</a>
<a data-link href="../../../engine/misc/faq/" class=""> FAQ</a>
<a data-link href="../../../engine/reference/glossary/" class=""> Docker Glossary</a>
</div>
</article>
</section>
<section data-accordion>
<article data-accordion>
<button style="visibility: hidden" data-control> Docs archive</button>
<div data-content>
<a data-link href="http://docs.docker.com/v1.7/" class=""> Version 1.7</a>
<a data-link href="http://docs.docker.com/v1.6/" class=""> Version 1.6</a>
<a data-link href="http://docs.docker.com/v1.5/" class=""> Version 1.5</a>
<a data-link href="http://docs.docker.com/v1.4/" class=""> Version 1.4</a>
</div>
</article>
</section>
</section>
<script>
$(document).ready(function () {
var $activeLink = $('#multiple [data-link].active');
var $accordions = $activeLink.parents('article[data-accordion]');
$($accordions.get().reverse()).each(function (index, accordion) {
var $accordion = $(accordion);
var $content = $accordion.find('[data-content]');
$accordion.addClass('open');
$content.css({'max-height': '100%'});
});
});
</script>
</div>
<div class="large-6 columns">
<section id="main">
<article id="content">
<h1 id="build-your-own-images">Build your own images</h1>
<p>Docker images are the basis of containers. Each time you&rsquo;ve used <code>docker run</code>
you told it which image you wanted. In the previous sections of the guide you
used Docker images that already exist, for example the <code>ubuntu</code> image and the
<code>training/webapp</code> image.</p>
<p>You also discovered that Docker stores downloaded images on the Docker host. If
an image isn&rsquo;t already present on the host then it&rsquo;ll be downloaded from a
registry: by default the <a href="https://registry.hub.docker.com">Docker Hub Registry</a>.</p>
<p>In this section you&rsquo;re going to explore Docker images a bit more
including:</p>
<ul>
<li>Managing and working with images locally on your Docker host.</li>
<li>Creating basic images.</li>
<li>Uploading images to <a href="https://registry.hub.docker.com">Docker Hub Registry</a>.</li>
</ul>
<h2 id="listing-images-on-the-host">Listing images on the host</h2>
<p>Let&rsquo;s start with listing the images you have locally on our host. You can
do this using the <code>docker images</code> command like so:</p>
<pre><code>$ docker images
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
ubuntu 14.04 1d073211c498 3 days ago 187.9 MB
busybox latest 2c5ac3f849df 5 days ago 1.113 MB
training/webapp latest 54bb4e8718e8 5 months ago 348.7 MB
</code></pre>
<p>You can see the images you&rsquo;ve previously used in the user guide.
Each has been downloaded from <a href="https://hub.docker.com">Docker Hub</a> when you
launched a container using that image. When you list images, you get three crucial pieces of information in the listing.</p>
<ul>
<li>What repository they came from, for example <code>ubuntu</code>.</li>
<li>The tags for each image, for example <code>14.04</code>.</li>
<li>The image ID of each image.</li>
</ul>
<blockquote>
<p><strong>Tip:</strong>
You can use <a href="https://github.com/justone/dockviz">a third-party dockviz tool</a>
or the <a href="https://imagelayers.io/">Image layers site</a> to display<br />
visualizations of image data.</p>
</blockquote>
<p>A repository potentially holds multiple variants of an image. In the case of
our <code>ubuntu</code> image you can see multiple variants covering Ubuntu 10.04, 12.04,
12.10, 13.04, 13.10 and 14.04. Each variant is identified by a tag and you can
refer to a tagged image like so:</p>
<pre><code>ubuntu:14.04
</code></pre>
<p>So when you run a container you refer to a tagged image like so:</p>
<pre><code>$ docker run -t -i ubuntu:14.04 /bin/bash
</code></pre>
<p>If instead you wanted to run an Ubuntu 12.04 image you&rsquo;d use:</p>
<pre><code>$ docker run -t -i ubuntu:12.04 /bin/bash
</code></pre>
<p>If you don&rsquo;t specify a variant, for example you just use <code>ubuntu</code>, then Docker
will default to using the <code>ubuntu:latest</code> image.</p>
<blockquote>
<p><strong>Tip:</strong>
You recommend you always use a specific tagged image, for example
<code>ubuntu:12.04</code>. That way you always know exactly what variant of an image is
being used.</p>
</blockquote>
<h2 id="getting-a-new-image">Getting a new image</h2>
<p>So how do you get new images? Well Docker will automatically download any image
you use that isn&rsquo;t already present on the Docker host. But this can potentially
add some time to the launch of a container. If you want to pre-load an image you
can download it using the <code>docker pull</code> command. Suppose you&rsquo;d like to
download the <code>centos</code> image.</p>
<pre><code>$ docker pull centos
Pulling repository centos
b7de3133ff98: Pulling dependent layers
5cc9e91966f7: Pulling fs layer
511136ea3c5a: Download complete
ef52fb1fe610: Download complete
. . .
Status: Downloaded newer image for centos
</code></pre>
<p>You can see that each layer of the image has been pulled down and now you
can run a container from this image and you won&rsquo;t have to wait to
download the image.</p>
<pre><code>$ docker run -t -i centos /bin/bash
bash-4.1#
</code></pre>
<h2 id="finding-images">Finding images</h2>
<p>One of the features of Docker is that a lot of people have created Docker
images for a variety of purposes. Many of these have been uploaded to
<a href="https://hub.docker.com">Docker Hub</a>. You can search these images on the
<a href="https://hub.docker.com">Docker Hub</a> website.</p>
<p><img src="../../../engine/userguide/search.png" alt="indexsearch" /></p>
<p>You can also search for images on the command line using the <code>docker search</code>
command. Suppose your team wants an image with Ruby and Sinatra installed on
which to do our web application development. You can search for a suitable image
by using the <code>docker search</code> command to find all the images that contain the
term <code>sinatra</code>.</p>
<pre><code>$ docker search sinatra
NAME DESCRIPTION STARS OFFICIAL AUTOMATED
training/sinatra Sinatra training image 0 [OK]
marceldegraaf/sinatra Sinatra test app 0
mattwarren/docker-sinatra-demo 0 [OK]
luisbebop/docker-sinatra-hello-world 0 [OK]
bmorearty/handson-sinatra handson-ruby + Sinatra for Hands on with D... 0
subwiz/sinatra 0
bmorearty/sinatra 0
. . .
</code></pre>
<p>You can see the command returns a lot of images that use the term <code>sinatra</code>.
You&rsquo;ve received a list of image names, descriptions, Stars (which measure the
social popularity of images - if a user likes an image then they can &ldquo;star&rdquo; it),
and the Official and Automated build statuses. <a href="https://docs.docker.com/docker-hub/official_repos">Official
Repositories</a> are a carefully
curated set of Docker repositories supported by Docker, Inc. Automated
repositories are <a href="../../../engine/userguide/dockerrepos/#automated-builds">Automated Builds</a> that allow
you to validate the source and content of an image.</p>
<p>You&rsquo;ve reviewed the images available to use and you decided to use the
<code>training/sinatra</code> image. So far you&rsquo;ve seen two types of images repositories,
images like <code>ubuntu</code>, which are called base or root images. These base images
are provided by Docker Inc and are built, validated and supported. These can be
identified by their single word names.</p>
<p>You&rsquo;ve also seen user images, for example the <code>training/sinatra</code> image you&rsquo;ve
chosen. A user image belongs to a member of the Docker community and is built
and maintained by them. You can identify user images as they are always
prefixed with the user name, here <code>training</code>, of the user that created them.</p>
<h2 id="pulling-our-image">Pulling our image</h2>
<p>You&rsquo;ve identified a suitable image, <code>training/sinatra</code>, and now you can download it using the <code>docker pull</code> command.</p>
<pre><code>$ docker pull training/sinatra
</code></pre>
<p>The team can now use this image by running their own containers.</p>
<pre><code>$ docker run -t -i training/sinatra /bin/bash
root@a8cb6ce02d85:/#
</code></pre>
<h2 id="creating-our-own-images">Creating our own images</h2>
<p>The team has found the <code>training/sinatra</code> image pretty useful but it&rsquo;s not quite
what they need and you need to make some changes to it. There are two ways you
can update and create images.</p>
<ol>
<li>You can update a container created from an image and commit the results to an image.</li>
<li>You can use a <code>Dockerfile</code> to specify instructions to create an image.</li>
</ol>
<h3 id="updating-and-committing-an-image">Updating and committing an image</h3>
<p>To update an image you first need to create a container from the image
you&rsquo;d like to update.</p>
<pre><code>$ docker run -t -i training/sinatra /bin/bash
root@0b2616b0e5a8:/#
</code></pre>
<blockquote>
<p><strong>Note:</strong>
Take note of the container ID that has been created, <code>0b2616b0e5a8</code>, as you&rsquo;ll
need it in a moment.</p>
</blockquote>
<p>Inside our running container let&rsquo;s add the <code>json</code> gem.</p>
<pre><code>root@0b2616b0e5a8:/# gem install json
</code></pre>
<p>Once this has completed let&rsquo;s exit our container using the <code>exit</code>
command.</p>
<p>Now you have a container with the change you want to make. You can then
commit a copy of this container to an image using the <code>docker commit</code>
command.</p>
<pre><code>$ docker commit -m &quot;Added json gem&quot; -a &quot;Kate Smith&quot; \
0b2616b0e5a8 ouruser/sinatra:v2
4f177bd27a9ff0f6dc2a830403925b5360bfe0b93d476f7fc3231110e7f71b1c
</code></pre>
<p>Here you&rsquo;ve used the <code>docker commit</code> command. You&rsquo;ve specified two flags: <code>-m</code>
and <code>-a</code>. The <code>-m</code> flag allows us to specify a commit message, much like you
would with a commit on a version control system. The <code>-a</code> flag allows us to
specify an author for our update.</p>
<p>You&rsquo;ve also specified the container you want to create this new image from,
<code>0b2616b0e5a8</code> (the ID you recorded earlier) and you&rsquo;ve specified a target for
the image:</p>
<pre><code>ouruser/sinatra:v2
</code></pre>
<p>Break this target down. It consists of a new user, <code>ouruser</code>, that you&rsquo;re
writing this image to. You&rsquo;ve also specified the name of the image, here you&rsquo;re
keeping the original image name <code>sinatra</code>. Finally you&rsquo;re specifying a tag for
the image: <code>v2</code>.</p>
<p>You can then look at our new <code>ouruser/sinatra</code> image using the <code>docker images</code>
command.</p>
<pre><code>$ docker images
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
training/sinatra latest 5bc342fa0b91 10 hours ago 446.7 MB
ouruser/sinatra v2 3c59e02ddd1a 10 hours ago 446.7 MB
ouruser/sinatra latest 5db5f8471261 10 hours ago 446.7 MB
</code></pre>
<p>To use our new image to create a container you can then:</p>
<pre><code>$ docker run -t -i ouruser/sinatra:v2 /bin/bash
root@78e82f680994:/#
</code></pre>
<h3 id="building-an-image-from-a-dockerfile">Building an image from a <code>Dockerfile</code></h3>
<p>Using the <code>docker commit</code> command is a pretty simple way of extending an image
but it&rsquo;s a bit cumbersome and it&rsquo;s not easy to share a development process for
images amongst a team. Instead you can use a new command, <code>docker build</code>, to
build new images from scratch.</p>
<p>To do this you create a <code>Dockerfile</code> that contains a set of instructions that
tell Docker how to build our image.</p>
<p>First, create a directory and a <code>Dockerfile</code>.</p>
<pre><code>$ mkdir sinatra
$ cd sinatra
$ touch Dockerfile
</code></pre>
<p>If you are using Docker Machine on Windows, you may access your host
directory by <code>cd</code> to <code>/c/Users/your_user_name</code>.</p>
<p>Each instruction creates a new layer of the image. Try a simple example now for
building your own Sinatra image for your fictitious development team.</p>
<pre><code># This is a comment
FROM ubuntu:14.04
MAINTAINER Kate Smith &lt;ksmith@example.com&gt;
RUN apt-get update &amp;&amp; apt-get install -y ruby ruby-dev
RUN gem install sinatra
</code></pre>
<p>Examine what your <code>Dockerfile</code> does. Each instruction prefixes a statement and
is capitalized.</p>
<pre><code>INSTRUCTION statement
</code></pre>
<blockquote>
<p><strong>Note:</strong> You use <code>#</code> to indicate a comment</p>
</blockquote>
<p>The first instruction <code>FROM</code> tells Docker what the source of our image is, in
this case you&rsquo;re basing our new image on an Ubuntu 14.04 image. The instruction uses the <code>MAINTAINER</code> instruction to specify who maintains the new image.</p>
<p>Lastly, you&rsquo;ve specified two <code>RUN</code> instructions. A <code>RUN</code> instruction executes
a command inside the image, for example installing a package. Here you&rsquo;re
updating our APT cache, installing Ruby and RubyGems and then installing the
Sinatra gem.</p>
<p>Now let&rsquo;s take our <code>Dockerfile</code> and use the <code>docker build</code> command to build an image.</p>
<pre><code>$ docker build -t ouruser/sinatra:v2 .
Sending build context to Docker daemon 2.048 kB
Sending build context to Docker daemon
Step 1 : FROM ubuntu:14.04
---&gt; e54ca5efa2e9
Step 2 : MAINTAINER Kate Smith &lt;ksmith@example.com&gt;
---&gt; Using cache
---&gt; 851baf55332b
Step 3 : RUN apt-get update &amp;&amp; apt-get install -y ruby ruby-dev
---&gt; Running in 3a2558904e9b
Selecting previously unselected package libasan0:amd64.
(Reading database ... 11518 files and directories currently installed.)
Preparing to unpack .../libasan0_4.8.2-19ubuntu1_amd64.deb ...
Unpacking libasan0:amd64 (4.8.2-19ubuntu1) ...
Selecting previously unselected package libatomic1:amd64.
Preparing to unpack .../libatomic1_4.8.2-19ubuntu1_amd64.deb ...
Unpacking libatomic1:amd64 (4.8.2-19ubuntu1) ...
Selecting previously unselected package libgmp10:amd64.
Preparing to unpack .../libgmp10_2%3a5.1.3+dfsg-1ubuntu1_amd64.deb ...
Unpacking libgmp10:amd64 (2:5.1.3+dfsg-1ubuntu1) ...
Selecting previously unselected package libisl10:amd64.
Preparing to unpack .../libisl10_0.12.2-1_amd64.deb ...
Unpacking libisl10:amd64 (0.12.2-1) ...
Selecting previously unselected package libcloog-isl4:amd64.
Preparing to unpack .../libcloog-isl4_0.18.2-1_amd64.deb ...
Unpacking libcloog-isl4:amd64 (0.18.2-1) ...
Selecting previously unselected package libgomp1:amd64.
Preparing to unpack .../libgomp1_4.8.2-19ubuntu1_amd64.deb ...
Unpacking libgomp1:amd64 (4.8.2-19ubuntu1) ...
Selecting previously unselected package libitm1:amd64.
Preparing to unpack .../libitm1_4.8.2-19ubuntu1_amd64.deb ...
Unpacking libitm1:amd64 (4.8.2-19ubuntu1) ...
Selecting previously unselected package libmpfr4:amd64.
Preparing to unpack .../libmpfr4_3.1.2-1_amd64.deb ...
Unpacking libmpfr4:amd64 (3.1.2-1) ...
Selecting previously unselected package libquadmath0:amd64.
Preparing to unpack .../libquadmath0_4.8.2-19ubuntu1_amd64.deb ...
Unpacking libquadmath0:amd64 (4.8.2-19ubuntu1) ...
Selecting previously unselected package libtsan0:amd64.
Preparing to unpack .../libtsan0_4.8.2-19ubuntu1_amd64.deb ...
Unpacking libtsan0:amd64 (4.8.2-19ubuntu1) ...
Selecting previously unselected package libyaml-0-2:amd64.
Preparing to unpack .../libyaml-0-2_0.1.4-3ubuntu3_amd64.deb ...
Unpacking libyaml-0-2:amd64 (0.1.4-3ubuntu3) ...
Selecting previously unselected package libmpc3:amd64.
Preparing to unpack .../libmpc3_1.0.1-1ubuntu1_amd64.deb ...
Unpacking libmpc3:amd64 (1.0.1-1ubuntu1) ...
Selecting previously unselected package openssl.
Preparing to unpack .../openssl_1.0.1f-1ubuntu2.4_amd64.deb ...
Unpacking openssl (1.0.1f-1ubuntu2.4) ...
Selecting previously unselected package ca-certificates.
Preparing to unpack .../ca-certificates_20130906ubuntu2_all.deb ...
Unpacking ca-certificates (20130906ubuntu2) ...
Selecting previously unselected package manpages.
Preparing to unpack .../manpages_3.54-1ubuntu1_all.deb ...
Unpacking manpages (3.54-1ubuntu1) ...
Selecting previously unselected package binutils.
Preparing to unpack .../binutils_2.24-5ubuntu3_amd64.deb ...
Unpacking binutils (2.24-5ubuntu3) ...
Selecting previously unselected package cpp-4.8.
Preparing to unpack .../cpp-4.8_4.8.2-19ubuntu1_amd64.deb ...
Unpacking cpp-4.8 (4.8.2-19ubuntu1) ...
Selecting previously unselected package cpp.
Preparing to unpack .../cpp_4%3a4.8.2-1ubuntu6_amd64.deb ...
Unpacking cpp (4:4.8.2-1ubuntu6) ...
Selecting previously unselected package libgcc-4.8-dev:amd64.
Preparing to unpack .../libgcc-4.8-dev_4.8.2-19ubuntu1_amd64.deb ...
Unpacking libgcc-4.8-dev:amd64 (4.8.2-19ubuntu1) ...
Selecting previously unselected package gcc-4.8.
Preparing to unpack .../gcc-4.8_4.8.2-19ubuntu1_amd64.deb ...
Unpacking gcc-4.8 (4.8.2-19ubuntu1) ...
Selecting previously unselected package gcc.
Preparing to unpack .../gcc_4%3a4.8.2-1ubuntu6_amd64.deb ...
Unpacking gcc (4:4.8.2-1ubuntu6) ...
Selecting previously unselected package libc-dev-bin.
Preparing to unpack .../libc-dev-bin_2.19-0ubuntu6_amd64.deb ...
Unpacking libc-dev-bin (2.19-0ubuntu6) ...
Selecting previously unselected package linux-libc-dev:amd64.
Preparing to unpack .../linux-libc-dev_3.13.0-30.55_amd64.deb ...
Unpacking linux-libc-dev:amd64 (3.13.0-30.55) ...
Selecting previously unselected package libc6-dev:amd64.
Preparing to unpack .../libc6-dev_2.19-0ubuntu6_amd64.deb ...
Unpacking libc6-dev:amd64 (2.19-0ubuntu6) ...
Selecting previously unselected package ruby.
Preparing to unpack .../ruby_1%3a1.9.3.4_all.deb ...
Unpacking ruby (1:1.9.3.4) ...
Selecting previously unselected package ruby1.9.1.
Preparing to unpack .../ruby1.9.1_1.9.3.484-2ubuntu1_amd64.deb ...
Unpacking ruby1.9.1 (1.9.3.484-2ubuntu1) ...
Selecting previously unselected package libruby1.9.1.
Preparing to unpack .../libruby1.9.1_1.9.3.484-2ubuntu1_amd64.deb ...
Unpacking libruby1.9.1 (1.9.3.484-2ubuntu1) ...
Selecting previously unselected package manpages-dev.
Preparing to unpack .../manpages-dev_3.54-1ubuntu1_all.deb ...
Unpacking manpages-dev (3.54-1ubuntu1) ...
Selecting previously unselected package ruby1.9.1-dev.
Preparing to unpack .../ruby1.9.1-dev_1.9.3.484-2ubuntu1_amd64.deb ...
Unpacking ruby1.9.1-dev (1.9.3.484-2ubuntu1) ...
Selecting previously unselected package ruby-dev.
Preparing to unpack .../ruby-dev_1%3a1.9.3.4_all.deb ...
Unpacking ruby-dev (1:1.9.3.4) ...
Setting up libasan0:amd64 (4.8.2-19ubuntu1) ...
Setting up libatomic1:amd64 (4.8.2-19ubuntu1) ...
Setting up libgmp10:amd64 (2:5.1.3+dfsg-1ubuntu1) ...
Setting up libisl10:amd64 (0.12.2-1) ...
Setting up libcloog-isl4:amd64 (0.18.2-1) ...
Setting up libgomp1:amd64 (4.8.2-19ubuntu1) ...
Setting up libitm1:amd64 (4.8.2-19ubuntu1) ...
Setting up libmpfr4:amd64 (3.1.2-1) ...
Setting up libquadmath0:amd64 (4.8.2-19ubuntu1) ...
Setting up libtsan0:amd64 (4.8.2-19ubuntu1) ...
Setting up libyaml-0-2:amd64 (0.1.4-3ubuntu3) ...
Setting up libmpc3:amd64 (1.0.1-1ubuntu1) ...
Setting up openssl (1.0.1f-1ubuntu2.4) ...
Setting up ca-certificates (20130906ubuntu2) ...
debconf: unable to initialize frontend: Dialog
debconf: (TERM is not set, so the dialog frontend is not usable.)
debconf: falling back to frontend: Readline
debconf: unable to initialize frontend: Readline
debconf: (This frontend requires a controlling tty.)
debconf: falling back to frontend: Teletype
Setting up manpages (3.54-1ubuntu1) ...
Setting up binutils (2.24-5ubuntu3) ...
Setting up cpp-4.8 (4.8.2-19ubuntu1) ...
Setting up cpp (4:4.8.2-1ubuntu6) ...
Setting up libgcc-4.8-dev:amd64 (4.8.2-19ubuntu1) ...
Setting up gcc-4.8 (4.8.2-19ubuntu1) ...
Setting up gcc (4:4.8.2-1ubuntu6) ...
Setting up libc-dev-bin (2.19-0ubuntu6) ...
Setting up linux-libc-dev:amd64 (3.13.0-30.55) ...
Setting up libc6-dev:amd64 (2.19-0ubuntu6) ...
Setting up manpages-dev (3.54-1ubuntu1) ...
Setting up libruby1.9.1 (1.9.3.484-2ubuntu1) ...
Setting up ruby1.9.1-dev (1.9.3.484-2ubuntu1) ...
Setting up ruby-dev (1:1.9.3.4) ...
Setting up ruby (1:1.9.3.4) ...
Setting up ruby1.9.1 (1.9.3.484-2ubuntu1) ...
Processing triggers for libc-bin (2.19-0ubuntu6) ...
Processing triggers for ca-certificates (20130906ubuntu2) ...
Updating certificates in /etc/ssl/certs... 164 added, 0 removed; done.
Running hooks in /etc/ca-certificates/update.d....done.
---&gt; c55c31703134
Removing intermediate container 3a2558904e9b
Step 4 : RUN gem install sinatra
---&gt; Running in 6b81cb6313e5
unable to convert &quot;\xC3&quot; to UTF-8 in conversion from ASCII-8BIT to UTF-8 to US-ASCII for README.rdoc, skipping
unable to convert &quot;\xC3&quot; to UTF-8 in conversion from ASCII-8BIT to UTF-8 to US-ASCII for README.rdoc, skipping
Successfully installed rack-1.5.2
Successfully installed tilt-1.4.1
Successfully installed rack-protection-1.5.3
Successfully installed sinatra-1.4.5
4 gems installed
Installing ri documentation for rack-1.5.2...
Installing ri documentation for tilt-1.4.1...
Installing ri documentation for rack-protection-1.5.3...
Installing ri documentation for sinatra-1.4.5...
Installing RDoc documentation for rack-1.5.2...
Installing RDoc documentation for tilt-1.4.1...
Installing RDoc documentation for rack-protection-1.5.3...
Installing RDoc documentation for sinatra-1.4.5...
---&gt; 97feabe5d2ed
Removing intermediate container 6b81cb6313e5
Successfully built 97feabe5d2ed
</code></pre>
<p>You&rsquo;ve specified our <code>docker build</code> command and used the <code>-t</code> flag to identify
our new image as belonging to the user <code>ouruser</code>, the repository name <code>sinatra</code>
and given it the tag <code>v2</code>.</p>
<p>You&rsquo;ve also specified the location of our <code>Dockerfile</code> using the <code>.</code> to
indicate a <code>Dockerfile</code> in the current directory.</p>
<blockquote>
<p><strong>Note:</strong>
You can also specify a path to a <code>Dockerfile</code>.</p>
</blockquote>
<p>Now you can see the build process at work. The first thing Docker does is
upload the build context: basically the contents of the directory you&rsquo;re
building in. This is done because the Docker daemon does the actual
build of the image and it needs the local context to do it.</p>
<p>Next you can see each instruction in the <code>Dockerfile</code> being executed
step-by-step. You can see that each step creates a new container, runs
the instruction inside that container and then commits that change -
just like the <code>docker commit</code> work flow you saw earlier. When all the
instructions have executed you&rsquo;re left with the <code>97feabe5d2ed</code> image
(also helpfully tagged as <code>ouruser/sinatra:v2</code>) and all intermediate
containers will get removed to clean things up.</p>
<blockquote>
<p><strong>Note:</strong>
An image can&rsquo;t have more than 127 layers regardless of the storage driver.
This limitation is set globally to encourage optimization of the overall
size of images.</p>
</blockquote>
<p>You can then create a container from our new image.</p>
<pre><code>$ docker run -t -i ouruser/sinatra:v2 /bin/bash
root@8196968dac35:/#
</code></pre>
<blockquote>
<p><strong>Note:</strong>
This is just a brief introduction to creating images. We&rsquo;ve
skipped a whole bunch of other instructions that you can use. We&rsquo;ll see more of
those instructions in later sections of the Guide or you can refer to the
<a href="../../../engine/reference/builder/"><code>Dockerfile</code></a> reference for a
detailed description and examples of every instruction.
To help you write a clear, readable, maintainable <code>Dockerfile</code>, you&rsquo;ve also
written a <a href="../../../engine/articles/dockerfile_best-practices/"><code>Dockerfile</code> Best Practices guide</a>.</p>
</blockquote>
<h2 id="setting-tags-on-an-image">Setting tags on an image</h2>
<p>You can also add a tag to an existing image after you commit or build it. We
can do this using the <code>docker tag</code> command. Now, add a new tag to your
<code>ouruser/sinatra</code> image.</p>
<pre><code>$ docker tag 5db5f8471261 ouruser/sinatra:devel
</code></pre>
<p>The <code>docker tag</code> command takes the ID of the image, here <code>5db5f8471261</code>, and our
user name, the repository name and the new tag.</p>
<p>Now, see your new tag using the <code>docker images</code> command.</p>
<pre><code>$ docker images ouruser/sinatra
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
ouruser/sinatra latest 5db5f8471261 11 hours ago 446.7 MB
ouruser/sinatra devel 5db5f8471261 11 hours ago 446.7 MB
ouruser/sinatra v2 5db5f8471261 11 hours ago 446.7 MB
</code></pre>
<h2 id="image-digests">Image Digests</h2>
<p>Images that use the v2 or later format have a content-addressable identifier
called a <code>digest</code>. As long as the input used to generate the image is
unchanged, the digest value is predictable. To list image digest values, use
the <code>--digests</code> flag:</p>
<pre><code>$ docker images --digests | head
REPOSITORY TAG DIGEST IMAGE ID CREATED VIRTUAL SIZE
ouruser/sinatra latest sha256:cbbf2f9a99b47fc460d422812b6a5adff7dfee951d8fa2e4a98caa0382cfbdbf 5db5f8471261 11 hours ago 446.7 MB
</code></pre>
<p>When pushing or pulling to a 2.0 registry, the <code>push</code> or <code>pull</code> command
output includes the image digest. You can <code>pull</code> using a digest value.</p>
<pre><code>$ docker pull ouruser/sinatra@cbbf2f9a99b47fc460d422812b6a5adff7dfee951d8fa2e4a98caa0382cfbdbf
</code></pre>
<p>You can also reference by digest in <code>create</code>, <code>run</code>, and <code>rmi</code> commands, as well as the
<code>FROM</code> image reference in a Dockerfile.</p>
<h2 id="push-an-image-to-docker-hub">Push an image to Docker Hub</h2>
<p>Once you&rsquo;ve built or created a new image you can push it to <a href="https://hub.docker.com">Docker
Hub</a> using the <code>docker push</code> command. This
allows you to share it with others, either publicly, or push it into <a href="https://registry.hub.docker.com/plans/">a
private repository</a>.</p>
<pre><code>$ docker push ouruser/sinatra
The push refers to a repository [ouruser/sinatra] (len: 1)
Sending image list
Pushing repository ouruser/sinatra (3 tags)
. . .
</code></pre>
<h2 id="remove-an-image-from-the-host">Remove an image from the host</h2>
<p>You can also remove images on your Docker host in a way <a href="../../../engine/userguide/usingdocker/">similar to
containers</a> using the <code>docker rmi</code> command.</p>
<p>Delete the <code>training/sinatra</code> image as you don&rsquo;t need it anymore.</p>
<pre><code>$ docker rmi training/sinatra
Untagged: training/sinatra:latest
Deleted: 5bc342fa0b91cabf65246837015197eecfa24b2213ed6a51a8974ae250fedd8d
Deleted: ed0fffdcdae5eb2c3a55549857a8be7fc8bc4241fb19ad714364cbfd7a56b22f
Deleted: 5c58979d73ae448df5af1d8142436d81116187a7633082650549c52c3a2418f0
</code></pre>
<blockquote>
<p><strong>Note:</strong> To remove an image from the host, please make sure
that there are no containers actively based on it.</p>
</blockquote>
<h1 id="next-steps">Next steps</h1>
<p>Until now you&rsquo;ve seen how to build individual applications inside Docker
containers. Now learn how to build whole application stacks with Docker
by networking together multiple Docker containers.</p>
<p>Go to <a href="../../../engine/userguide/networkingcontainers/">Network containers</a>.</p>
</article>
</section>
</div>
<div id="toc" class="large-3 columns toc ">
On this page:
<nav id="TableOfContents">
<ul>
<li><a href="#build-your-own-images">Build your own images</a>
<ul>
<li><a href="#listing-images-on-the-host">Listing images on the host</a></li>
<li><a href="#getting-a-new-image">Getting a new image</a></li>
<li><a href="#finding-images">Finding images</a></li>
<li><a href="#pulling-our-image">Pulling our image</a></li>
<li><a href="#creating-our-own-images">Creating our own images</a>
<ul>
<li><a href="#updating-and-committing-an-image">Updating and committing an image</a></li>
<li><a href="#building-an-image-from-a-dockerfile">Building an image from a <code>Dockerfile</code></a></li>
</ul></li>
<li><a href="#setting-tags-on-an-image">Setting tags on an image</a></li>
<li><a href="#image-digests">Image Digests</a></li>
<li><a href="#push-an-image-to-docker-hub">Push an image to Docker Hub</a></li>
<li><a href="#remove-an-image-from-the-host">Remove an image from the host</a></li>
</ul></li>
<li><a href="#next-steps">Next steps</a></li>
</ul>
</nav>
</div>
</div>
<footer class="main-footer">
<div class="row">
</div>
<div class="row">
</div>
<div id="buildinfo">
Nov 3, 2015 at 7:59pm (PST)
{
"docker/compose": {
"ref": "docs",
"repos": [
"git@github.com:docker/compose.git"
],
"sha": "9c8173dbfda93baef214359991b6a8a54172f6ae"
},
"docker/docker-hub": {
"ref": "master",
"repos": [
"git@github.com:docker/hub2-demo.git"
],
"sha": "4b2e522c81c860d63b126342a6b981ac0ff1605c"
},
"docker/docker-trusted-registry": {
"ref": "docs",
"repos": [
"git@github.com:docker/dhe-deploy.git"
],
"sha": "b8988465878952f2e2c2472e8fc5fd35e5975fbf"
},
"docker/docs-base": {
"ref": "hugo-github-linking",
"repos": [
"git@github.com:docker/docs-base.git"
],
"sha": "dc98c0381a6cc311c9e3189dc78a3c7e62e5a205"
},
"docker/engine": {
"ref": "master",
"repos": [
"git@github.com:docker/docker.git"
],
"sha": "474b16af8ecfe94ec635dfac60025348d3186aa3"
},
"docker/machine": {
"ref": "master",
"repos": [
"git@github.com:docker/machine.git"
],
"sha": "786437901c0c883ecb59c1e0531654c1d89b326d"
},
"docker/opensource": {
"ref": "master",
"repos": [
"git@github.com:docker/opensource.git"
],
"sha": "0cd99bcdd876ca0293d8944980c79f32064b6354"
},
"docker/registry": {
"ref": "master",
"repos": [
"git@github.com:docker/distribution.git"
],
"sha": "a9da0e510032314910b5405acc50873ab2fa2e5a"
},
"docker/swarm": {
"ref": "master",
"repos": [
"git@github.com:docker/swarm.git"
],
"sha": "087e2452f3ec474f112b4e5b8c52b8dacb5751be"
},
"docker/tutorials": {
"ref": "master",
"repos": [
"git@github.com:docker/tutorials.git"
],
"sha": "cb55d4de0df55e22f443aac664d66f092f06c56b"
},
"docs.docker.com": {
"ref": "refs/heads/1-9-release",
"repos": [
"git@github.com:moxiegirl/docs.docker.com.git",
"git@github.com:docker/docs.docker.com.git"
],
"sha": "5878eae5de6f012c67a2a4772327c9948274c351"
},
"kitematic/kitematic": {
"ref": "master",
"repos": [
"git@github.com:kitematic/kitematic.git"
],
"sha": "e533ed35d2eab31ce528675b0665f97516b4147b"
}
} </div>
</footer>
<link rel="stylesheet" href="../../../highlight/styles/github.css">
<script src="../../../highlight/highlight.pack.js"></script>
<script>hljs.initHighlightingOnLoad();</script>
<script src="../../../dist/assets/js/all.js"></script>
<script>
$( 'nav li:has(ul)' ).doubleTapToGo();
</script>
<script>
;(function ( $, window, document, undefined ) {
var pluginName = 'accordion',
defaults = {
transitionSpeed: 300,
transitionEasing: 'ease',
controlElement: '[data-control]',
contentElement: '[data-content]',
groupElement: '[data-accordion-group]',
singleOpen: true
};
function Accordion(element, options) {
this.element = element;
this.options = $.extend({}, defaults, options);
this._defaults = defaults;
this._name = pluginName;
this.init();
}
Accordion.prototype.init = function () {
var self = this,
opts = self.options;
var $accordion = $(self.element),
$controls = $accordion.find('> ' + opts.controlElement),
$content = $accordion.find('> ' + opts.contentElement);
var accordionParentsQty = $accordion.parents('[data-accordion]').length,
accordionHasParent = accordionParentsQty > 0;
var closedCSS = { 'max-height': 0, 'overflow': 'hidden' };
var CSStransitions = supportsTransitions();
function debounce(func, threshold, execAsap) {
var timeout;
return function debounced() {
var obj = this,
args = arguments;
function delayed() {
if (!execAsap) func.apply(obj, args);
timeout = null;
};
if (timeout) clearTimeout(timeout);
else if (execAsap) func.apply(obj, args);
timeout = setTimeout(delayed, threshold || 100);
};
}
function supportsTransitions() {
var b = document.body || document.documentElement,
s = b.style,
p = 'transition';
if (typeof s[p] == 'string') {
return true;
}
var v = ['Moz', 'webkit', 'Webkit', 'Khtml', 'O', 'ms'];
p = 'Transition';
for (var i=0; i<v.length; i++) {
if (typeof s[v[i] + p] == 'string') {
return true;
}
}
return false;
}
function requestAnimFrame(cb) {
if(window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame) {
return requestAnimationFrame(cb) ||
webkitRequestAnimationFrame(cb) ||
mozRequestAnimationFrame(cb);
} else {
return setTimeout(cb, 1000 / 60);
}
}
function toggleTransition($el, remove) {
if(!remove) {
$content.css({
'-webkit-transition': 'max-height ' + opts.transitionSpeed + 'ms ' + opts.transitionEasing,
'transition': 'max-height ' + opts.transitionSpeed + 'ms ' + opts.transitionEasing
});
} else {
$content.css({
'-webkit-transition': '',
'transition': ''
});
}
}
function calculateHeight($el) {
var height = 0;
$el.children().each(function() {
height = height + $(this).outerHeight(true);
});
$el.data('oHeight', height);
}
function updateParentHeight($parentAccordion, $currentAccordion, qty, operation) {
var $content = $parentAccordion.filter('.open').find('> [data-content]'),
$childs = $content.find('[data-accordion].open > [data-content]'),
$matched;
if(!opts.singleOpen) {
$childs = $childs.not($currentAccordion.siblings('[data-accordion].open').find('> [data-content]'));
}
$matched = $content.add($childs);
if($parentAccordion.hasClass('open')) {
$matched.each(function() {
var currentHeight = $(this).data('oHeight');
switch (operation) {
case '+':
$(this).data('oHeight', currentHeight + qty);
break;
case '-':
$(this).data('oHeight', currentHeight - qty);
break;
default:
throw 'updateParentHeight method needs an operation';
}
$(this).css('max-height', $(this).data('oHeight'));
});
}
}
function refreshHeight($accordion) {
if($accordion.hasClass('open')) {
var $content = $accordion.find('> [data-content]'),
$childs = $content.find('[data-accordion].open > [data-content]'),
$matched = $content.add($childs);
calculateHeight($matched);
$matched.css('max-height', $matched.data('oHeight'));
}
}
function closeAccordion($accordion, $content) {
$accordion.trigger('accordion.close');
if(CSStransitions) {
if(accordionHasParent) {
var $parentAccordions = $accordion.parents('[data-accordion]');
updateParentHeight($parentAccordions, $accordion, $content.data('oHeight'), '-');
}
$content.css(closedCSS);
$accordion.removeClass('open');
} else {
$content.css('max-height', $content.data('oHeight'));
$content.animate(closedCSS, opts.transitionSpeed);
$accordion.removeClass('open');
}
}
function openAccordion($accordion, $content) {
$accordion.trigger('accordion.open');
if(CSStransitions) {
toggleTransition($content);
if(accordionHasParent) {
var $parentAccordions = $accordion.parents('[data-accordion]');
updateParentHeight($parentAccordions, $accordion, $content.data('oHeight'), '+');
}
requestAnimFrame(function() {
$content.css('max-height', $content.data('oHeight'));
});
$accordion.addClass('open');
} else {
$content.animate({
'max-height': $content.data('oHeight')
}, opts.transitionSpeed, function() {
$content.css({'max-height': 'none'});
});
$accordion.addClass('open');
}
}
function closeSiblingAccordions($accordion) {
var $accordionGroup = $accordion.closest(opts.groupElement);
var $siblings = $accordion.siblings('[data-accordion]').filter('.open'),
$siblingsChildren = $siblings.find('[data-accordion]').filter('.open');
var $otherAccordions = $siblings.add($siblingsChildren);
$otherAccordions.each(function() {
var $accordion = $(this),
$content = $accordion.find(opts.contentElement);
closeAccordion($accordion, $content);
});
$otherAccordions.removeClass('open');
}
function toggleAccordion() {
var isAccordionGroup = (opts.singleOpen) ? $accordion.parents(opts.groupElement).length > 0 : false;
calculateHeight($content);
if(isAccordionGroup) {
closeSiblingAccordions($accordion);
}
if($accordion.hasClass('open')) {
closeAccordion($accordion, $content);
} else {
openAccordion($accordion, $content);
}
}
function addEventListeners() {
$controls.on('click', toggleAccordion);
$controls.on('accordion.toggle', function() {
if(opts.singleOpen && $controls.length > 1) {
return false;
}
toggleAccordion();
});
$(window).on('resize', debounce(function() {
refreshHeight($accordion);
}));
}
function setup() {
$content.each(function() {
var $curr = $(this);
if($curr.css('max-height') != 0) {
if(!$curr.closest('[data-accordion]').hasClass('open')) {
$curr.css({ 'max-height': 0, 'overflow': 'hidden' });
} else {
toggleTransition($curr);
calculateHeight($curr);
$curr.css('max-height', $curr.data('oHeight'));
}
}
});
if(!$accordion.attr('data-accordion')) {
$accordion.attr('data-accordion', '');
$accordion.find(opts.controlElement).attr('data-control', '');
$accordion.find(opts.contentElement).attr('data-content', '');
}
}
setup();
addEventListeners();
};
$.fn[pluginName] = function ( options ) {
return this.each(function () {
if (!$.data(this, 'plugin_' + pluginName)) {
$.data(this, 'plugin_' + pluginName,
new Accordion( this, options ));
}
});
}
})( jQuery, window, document );
$(document).ready(function() {
$('#multiple [data-accordion]').accordion({
singleOpen: false
});
});
</script>
<script src="/dist/assets/js/bootstrap-3.0.3.min.js"></script>
<script src="/dist/assets/js/archive.js"></script>
<script type="text/javascript">
!function(){var analytics=window.analytics=window.analytics||[];if(!analytics.initialize)if(analytics.invoked)window.console&&console.error&&console.error("Segment snippet included twice.");else{analytics.invoked=!0;analytics.methods=["trackSubmit","trackClick","trackLink","trackForm","pageview","identify","reset","group","track","ready","alias","debug","page","once","off","on"];analytics.factory=function(t){return function(){var e=Array.prototype.slice.call(arguments);e.unshift(t);analytics.push(e);return analytics}};for(var t=0;t<analytics.methods.length;t++){var e=analytics.methods[t];analytics[e]=analytics.factory(e)}analytics.load=function(t){var e=document.createElement("script");e.type="text/javascript";e.async=!0;e.src=("https:"===document.location.protocol?"https://":"http://")+"cdn.segment.com/analytics.js/v1/"+t+"/analytics.min.js";var n=document.getElementsByTagName("script")[0];n.parentNode.insertBefore(e,n)};analytics.SNIPPET_VERSION="4.0.0";
analytics.load("IWj9D0UpZHZdZUZX9jl98PcpBFWBnBMy");
analytics.page();
}}();
</script>