mirror of
https://github.com/docker/docs.git
synced 2026-03-29 15:28:51 +07:00
3976 lines
160 KiB
HTML
3976 lines
160 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="Configure containers at runtime">
|
||
<meta name="keywords" content="[docker, run, configure, runtime]">
|
||
<title>Docker run reference </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 & 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=""> 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 & 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 & 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 & 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 & 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 & Repos API: Intro & 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=" active"> 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">
|
||
|
||
|
||
<!-- TODO (@thaJeztah) define more flexible table/td classes -->
|
||
|
||
<p><style>
|
||
.content-body table .no-wrap {
|
||
white-space: nowrap;
|
||
}
|
||
</style></p>
|
||
|
||
<h1 id="docker-run-reference">Docker run reference</h1>
|
||
|
||
<p>Docker runs processes in isolated containers. A container is a process
|
||
which runs on a host. The host may be local or remote. When an operator
|
||
executes <code>docker run</code>, the container process that runs is isolated in
|
||
that it has its own file system, its own networking, and its own
|
||
isolated process tree separate from the host.</p>
|
||
|
||
<p>This page details how to use the <code>docker run</code> command to define the
|
||
container’s resources at runtime.</p>
|
||
|
||
<h2 id="general-form">General form</h2>
|
||
|
||
<p>The basic <code>docker run</code> command takes this form:</p>
|
||
|
||
<pre><code>$ docker run [OPTIONS] IMAGE[:TAG|@DIGEST] [COMMAND] [ARG...]
|
||
</code></pre>
|
||
|
||
<p>The <code>docker run</code> command must specify an <a href="../../../engine/reference/glossary/#image"><em>IMAGE</em></a>
|
||
to derive the container from. An image developer can define image
|
||
defaults related to:</p>
|
||
|
||
<ul>
|
||
<li>detached or foreground running</li>
|
||
<li>container identification</li>
|
||
<li>network settings</li>
|
||
<li>runtime constraints on CPU and memory</li>
|
||
<li>privileges and LXC configuration</li>
|
||
</ul>
|
||
|
||
<p>With the <code>docker run [OPTIONS]</code> an operator can add to or override the
|
||
image defaults set by a developer. And, additionally, operators can
|
||
override nearly all the defaults set by the Docker runtime itself. The
|
||
operator’s ability to override image and Docker runtime defaults is why
|
||
<a href="../../../engine/reference/commandline/run/"><em>run</em></a> has more options than any
|
||
other <code>docker</code> command.</p>
|
||
|
||
<p>To learn how to interpret the types of <code>[OPTIONS]</code>, see <a href="../../../engine/reference/commandline/cli/#option-types"><em>Option
|
||
types</em></a>.</p>
|
||
|
||
<blockquote>
|
||
<p><strong>Note</strong>: Depending on your Docker system configuration, you may be
|
||
required to preface the <code>docker run</code> command with <code>sudo</code>. To avoid
|
||
having to use <code>sudo</code> with the <code>docker</code> command, your system
|
||
administrator can create a Unix group called <code>docker</code> and add users to
|
||
it. For more information about this configuration, refer to the Docker
|
||
installation documentation for your operating system.</p>
|
||
</blockquote>
|
||
|
||
<h2 id="operator-exclusive-options">Operator exclusive options</h2>
|
||
|
||
<p>Only the operator (the person executing <code>docker run</code>) can set the
|
||
following options.</p>
|
||
|
||
<ul>
|
||
<li><a href="#detached-vs-foreground">Detached vs foreground</a>
|
||
|
||
<ul>
|
||
<li><a href="#detached-d">Detached (-d)</a></li>
|
||
<li><a href="#foreground">Foreground</a></li>
|
||
</ul></li>
|
||
<li><a href="#container-identification">Container identification</a>
|
||
|
||
<ul>
|
||
<li><a href="#name-name">Name (–name)</a></li>
|
||
<li><a href="#pid-equivalent">PID equivalent</a></li>
|
||
</ul></li>
|
||
<li><a href="#ipc-settings-ipc">IPC settings (–ipc)</a></li>
|
||
<li><a href="#network-settings">Network settings</a></li>
|
||
<li><a href="#restart-policies-restart">Restart policies (–restart)</a></li>
|
||
<li><a href="#clean-up-rm">Clean up (–rm)</a></li>
|
||
<li><a href="#runtime-constraints-on-resources">Runtime constraints on resources</a></li>
|
||
<li><a href="#runtime-privilege-linux-capabilities-and-lxc-configuration">Runtime privilege, Linux capabilities, and LXC configuration</a></li>
|
||
</ul>
|
||
|
||
<h2 id="detached-vs-foreground">Detached vs foreground</h2>
|
||
|
||
<p>When starting a Docker container, you must first decide if you want to
|
||
run the container in the background in a “detached” mode or in the
|
||
default foreground mode:</p>
|
||
|
||
<pre><code>-d=false: Detached mode: Run container in the background, print new container id
|
||
</code></pre>
|
||
|
||
<h3 id="detached-d">Detached (-d)</h3>
|
||
|
||
<p>To start a container in detached mode, you use <code>-d=true</code> or just <code>-d</code> option. By
|
||
design, containers started in detached mode exit when the root process used to
|
||
run the container exits. A container in detached mode cannot be automatically
|
||
removed when it stops, this means you cannot use the <code>--rm</code> option with <code>-d</code> option.</p>
|
||
|
||
<p>Do not pass a <code>service x start</code> command to a detached container. For example, this
|
||
command attempts to start the <code>nginx</code> service.</p>
|
||
|
||
<pre><code>$ docker run -d -p 80:80 my_image service nginx start
|
||
</code></pre>
|
||
|
||
<p>This succeeds in starting the <code>nginx</code> service inside the container. However, it
|
||
fails the detached container paradigm in that, the root process (<code>service nginx
|
||
start</code>) returns and the detached container stops as designed. As a result, the
|
||
<code>nginx</code> service is started but could not be used. Instead, to start a process
|
||
such as the <code>nginx</code> web server do the following:</p>
|
||
|
||
<pre><code>$ docker run -d -p 80:80 my_image nginx -g 'daemon off;'
|
||
</code></pre>
|
||
|
||
<p>To do input/output with a detached container use network connections or shared
|
||
volumes. These are required because the container is no longer listening to the
|
||
command line where <code>docker run</code> was run.</p>
|
||
|
||
<p>To reattach to a detached container, use <code>docker</code>
|
||
<a href="../../../engine/reference/commandline/attach/"><em>attach</em></a> command.</p>
|
||
|
||
<h3 id="foreground">Foreground</h3>
|
||
|
||
<p>In foreground mode (the default when <code>-d</code> is not specified), <code>docker
|
||
run</code> can start the process in the container and attach the console to
|
||
the process’s standard input, output, and standard error. It can even
|
||
pretend to be a TTY (this is what most command line executables expect)
|
||
and pass along signals. All of that is configurable:</p>
|
||
|
||
<pre><code>-a=[] : Attach to `STDIN`, `STDOUT` and/or `STDERR`
|
||
-t=false : Allocate a pseudo-tty
|
||
--sig-proxy=true: Proxify all received signal to the process (non-TTY mode only)
|
||
-i=false : Keep STDIN open even if not attached
|
||
</code></pre>
|
||
|
||
<p>If you do not specify <code>-a</code> then Docker will <a href="https://github.com/docker/docker/blob/75a7f4d90cde0295bcfb7213004abce8d4779b75/commands.go#L1797">attach all standard
|
||
streams</a>.
|
||
You can specify to which of the three standard streams (<code>STDIN</code>, <code>STDOUT</code>,
|
||
<code>STDERR</code>) you’d like to connect instead, as in:</p>
|
||
|
||
<pre><code>$ docker run -a stdin -a stdout -i -t ubuntu /bin/bash
|
||
</code></pre>
|
||
|
||
<p>For interactive processes (like a shell), you must use <code>-i -t</code> together in
|
||
order to allocate a tty for the container process. <code>-i -t</code> is often written <code>-it</code>
|
||
as you’ll see in later examples. Specifying <code>-t</code> is forbidden when the client
|
||
standard output is redirected or piped, such as in:
|
||
<code>echo test | docker run -i busybox cat</code>.</p>
|
||
|
||
<blockquote>
|
||
<p><strong>Note</strong>: A process running as PID 1 inside a container is treated
|
||
specially by Linux: it ignores any signal with the default action.
|
||
So, the process will not terminate on <code>SIGINT</code> or <code>SIGTERM</code> unless it is
|
||
coded to do so.</p>
|
||
</blockquote>
|
||
|
||
<h2 id="container-identification">Container identification</h2>
|
||
|
||
<h3 id="name-name">Name (–name)</h3>
|
||
|
||
<p>The operator can identify a container in three ways:</p>
|
||
|
||
<ul>
|
||
<li>UUID long identifier
|
||
(“f78375b1c487e03c9438c729345e54db9d20cfa2ac1fc3494b6eb60872e74778”)</li>
|
||
<li>UUID short identifier (“f78375b1c487”)</li>
|
||
<li>Name (“evil_ptolemy”)</li>
|
||
</ul>
|
||
|
||
<p>The UUID identifiers come from the Docker daemon. If you do not assign a
|
||
container name with the <code>--name</code> option, then the daemon generates a random
|
||
string name for you. Defining a <code>name</code> can be a handy way to add meaning to a
|
||
container. If you specify a <code>name</code>, you can use it when referencing the
|
||
container within a Docker network. This works for both background and foreground
|
||
Docker containers.</p>
|
||
|
||
<p><strong>Note</strong>: Containers on the default bridge network must be linked to communicate by name.</p>
|
||
|
||
<h3 id="pid-equivalent">PID equivalent</h3>
|
||
|
||
<p>Finally, to help with automation, you can have Docker write the
|
||
container ID out to a file of your choosing. This is similar to how some
|
||
programs might write out their process ID to a file (you’ve seen them as
|
||
PID files):</p>
|
||
|
||
<pre><code>--cidfile="": Write the container ID to the file
|
||
</code></pre>
|
||
|
||
<h3 id="image-tag">Image[:tag]</h3>
|
||
|
||
<p>While not strictly a means of identifying a container, you can specify a version of an
|
||
image you’d like to run the container with by adding <code>image[:tag]</code> to the command. For
|
||
example, <code>docker run ubuntu:14.04</code>.</p>
|
||
|
||
<h3 id="image-digest">Image[@digest]</h3>
|
||
|
||
<p>Images using the v2 or later image format have a content-addressable identifier
|
||
called a digest. As long as the input used to generate the image is unchanged,
|
||
the digest value is predictable and referenceable.</p>
|
||
|
||
<h2 id="pid-settings-pid">PID settings (–pid)</h2>
|
||
|
||
<pre><code>--pid="" : Set the PID (Process) Namespace mode for the container,
|
||
'host': use the host's PID namespace inside the container
|
||
</code></pre>
|
||
|
||
<p>By default, all containers have the PID namespace enabled.</p>
|
||
|
||
<p>PID namespace provides separation of processes. The PID Namespace removes the
|
||
view of the system processes, and allows process ids to be reused including
|
||
pid 1.</p>
|
||
|
||
<p>In certain cases you want your container to share the host’s process namespace,
|
||
basically allowing processes within the container to see all of the processes
|
||
on the system. For example, you could build a container with debugging tools
|
||
like <code>strace</code> or <code>gdb</code>, but want to use these tools when debugging processes
|
||
within the container.</p>
|
||
|
||
<pre><code>$ docker run --pid=host rhel7 strace -p 1234
|
||
</code></pre>
|
||
|
||
<p>This command would allow you to use <code>strace</code> inside the container on pid 1234 on
|
||
the host.</p>
|
||
|
||
<h2 id="uts-settings-uts">UTS settings (–uts)</h2>
|
||
|
||
<pre><code>--uts="" : Set the UTS namespace mode for the container,
|
||
'host': use the host's UTS namespace inside the container
|
||
</code></pre>
|
||
|
||
<p>The UTS namespace is for setting the hostname and the domain that is visible
|
||
to running processes in that namespace. By default, all containers, including
|
||
those with <code>--net=host</code>, have their own UTS namespace. The <code>host</code> setting will
|
||
result in the container using the same UTS namespace as the host.</p>
|
||
|
||
<p>You may wish to share the UTS namespace with the host if you would like the
|
||
hostname of the container to change as the hostname of the host changes. A
|
||
more advanced use case would be changing the host’s hostname from a container.</p>
|
||
|
||
<blockquote>
|
||
<p><strong>Note</strong>: <code>--uts="host"</code> gives the container full access to change the
|
||
hostname of the host and is therefore considered insecure.</p>
|
||
</blockquote>
|
||
|
||
<h2 id="ipc-settings-ipc">IPC settings (–ipc)</h2>
|
||
|
||
<pre><code>--ipc="" : Set the IPC mode for the container,
|
||
'container:<name|id>': reuses another container's IPC namespace
|
||
'host': use the host's IPC namespace inside the container
|
||
</code></pre>
|
||
|
||
<p>By default, all containers have the IPC namespace enabled.</p>
|
||
|
||
<p>IPC (POSIX/SysV IPC) namespace provides separation of named shared memory
|
||
segments, semaphores and message queues.</p>
|
||
|
||
<p>Shared memory segments are used to accelerate inter-process communication at
|
||
memory speed, rather than through pipes or through the network stack. Shared
|
||
memory is commonly used by databases and custom-built (typically C/OpenMPI,
|
||
C++/using boost libraries) high performance applications for scientific
|
||
computing and financial services industries. If these types of applications
|
||
are broken into multiple containers, you might need to share the IPC mechanisms
|
||
of the containers.</p>
|
||
|
||
<h2 id="network-settings">Network settings</h2>
|
||
|
||
<pre><code>--dns=[] : Set custom dns servers for the container
|
||
--net="bridge" : Connects a container to a network
|
||
'bridge': creates a new network stack for the container on the docker bridge
|
||
'none': no networking for this container
|
||
'container:<name|id>': reuses another container network stack
|
||
'host': use the host network stack inside the container
|
||
'NETWORK': connects the container to user-created network using `docker network create` command
|
||
--add-host="" : Add a line to /etc/hosts (host:IP)
|
||
--mac-address="" : Sets the container's Ethernet device's MAC address
|
||
</code></pre>
|
||
|
||
<p>By default, all containers have networking enabled and they can make any
|
||
outgoing connections. The operator can completely disable networking
|
||
with <code>docker run --net none</code> which disables all incoming and outgoing
|
||
networking. In cases like this, you would perform I/O through files or
|
||
<code>STDIN</code> and <code>STDOUT</code> only.</p>
|
||
|
||
<p>Publishing ports and linking to other containers only works with the the default (bridge). The linking feature is a legacy feature. You should always prefer using Docker network drivers over linking.</p>
|
||
|
||
<p>Your container will use the same DNS servers as the host by default, but
|
||
you can override this with <code>--dns</code>.</p>
|
||
|
||
<p>By default, the MAC address is generated using the IP address allocated to the
|
||
container. You can set the container’s MAC address explicitly by providing a
|
||
MAC address via the <code>--mac-address</code> parameter (format:<code>12:34:56:78:9a:bc</code>).</p>
|
||
|
||
<p>Supported networks :</p>
|
||
|
||
<table>
|
||
<thead>
|
||
<tr>
|
||
<th class="no-wrap">Network</th>
|
||
<th>Description</th>
|
||
</tr>
|
||
</thead>
|
||
<tbody>
|
||
<tr>
|
||
<td class="no-wrap"><strong>none</strong></td>
|
||
<td>
|
||
No networking in the container.
|
||
</td>
|
||
</tr>
|
||
<tr>
|
||
<td class="no-wrap"><strong>bridge</strong> (default)</td>
|
||
<td>
|
||
Connect the container to the bridge via veth interfaces.
|
||
</td>
|
||
</tr>
|
||
<tr>
|
||
<td class="no-wrap"><strong>host</strong></td>
|
||
<td>
|
||
Use the host's network stack inside the container.
|
||
</td>
|
||
</tr>
|
||
<tr>
|
||
<td class="no-wrap"><strong>container</strong>:<name|id></td>
|
||
<td>
|
||
Use the network stack of another container, specified via
|
||
its *name* or *id*.
|
||
</td>
|
||
</tr>
|
||
<tr>
|
||
<td class="no-wrap"><strong>NETWORK</strong></td>
|
||
<td>
|
||
Connects the container to a user created network (using `docker network create` command)
|
||
</td>
|
||
</tr>
|
||
</tbody>
|
||
</table>
|
||
|
||
<h4 id="network-none">Network: none</h4>
|
||
|
||
<p>With the network is <code>none</code> a container will not have
|
||
access to any external routes. The container will still have a
|
||
<code>loopback</code> interface enabled in the container but it does not have any
|
||
routes to external traffic.</p>
|
||
|
||
<h4 id="network-bridge">Network: bridge</h4>
|
||
|
||
<p>With the network set to <code>bridge</code> a container will use docker’s
|
||
default networking setup. A bridge is setup on the host, commonly named
|
||
<code>docker0</code>, and a pair of <code>veth</code> interfaces will be created for the
|
||
container. One side of the <code>veth</code> pair will remain on the host attached
|
||
to the bridge while the other side of the pair will be placed inside the
|
||
container’s namespaces in addition to the <code>loopback</code> interface. An IP
|
||
address will be allocated for containers on the bridge’s network and
|
||
traffic will be routed though this bridge to the container.</p>
|
||
|
||
<p>Containers can communicate via their IP addresses by default. To communicate by
|
||
name, they must be linked.</p>
|
||
|
||
<h4 id="network-host">Network: host</h4>
|
||
|
||
<p>With the network set to <code>host</code> a container will share the host’s
|
||
network stack and all interfaces from the host will be available to the
|
||
container. The container’s hostname will match the hostname on the host
|
||
system. Note that <code>--add-host</code> <code>--hostname</code> <code>--dns</code> <code>--dns-search</code>
|
||
<code>--dns-opt</code> and <code>--mac-address</code> are invalid in <code>host</code> netmode.</p>
|
||
|
||
<p>Compared to the default <code>bridge</code> mode, the <code>host</code> mode gives <em>significantly</em>
|
||
better networking performance since it uses the host’s native networking stack
|
||
whereas the bridge has to go through one level of virtualization through the
|
||
docker daemon. It is recommended to run containers in this mode when their
|
||
networking performance is critical, for example, a production Load Balancer
|
||
or a High Performance Web Server.</p>
|
||
|
||
<blockquote>
|
||
<p><strong>Note</strong>: <code>--net="host"</code> gives the container full access to local system
|
||
services such as D-bus and is therefore considered insecure.</p>
|
||
</blockquote>
|
||
|
||
<h4 id="network-container">Network: container</h4>
|
||
|
||
<p>With the network set to <code>container</code> a container will share the
|
||
network stack of another container. The other container’s name must be
|
||
provided in the format of <code>--net container:<name|id></code>. Note that <code>--add-host</code>
|
||
<code>--hostname</code> <code>--dns</code> <code>--dns-search</code> <code>--dns-opt</code> and <code>--mac-address</code> are
|
||
invalid in <code>container</code> netmode, and <code>--publish</code> <code>--publish-all</code> <code>--expose</code> are
|
||
also invalid in <code>container</code> netmode.</p>
|
||
|
||
<p>Example running a Redis container with Redis binding to <code>localhost</code> then
|
||
running the <code>redis-cli</code> command and connecting to the Redis server over the
|
||
<code>localhost</code> interface.</p>
|
||
|
||
<pre><code>$ docker run -d --name redis example/redis --bind 127.0.0.1
|
||
$ # use the redis container's network stack to access localhost
|
||
$ docker run --rm -it --net container:redis example/redis-cli -h 127.0.0.1
|
||
</code></pre>
|
||
|
||
<h4 id="user-defined-network">User-defined network</h4>
|
||
|
||
<p>You can create a network using a Docker network driver or an external network
|
||
driver plugin. You can connect multiple containers to the same network. Once
|
||
connected to a user-defined network, the containers can communicate easily using
|
||
only another container’s IP address or name.</p>
|
||
|
||
<p>For <code>overlay</code> networks or custom plugins that support multi-host connectivity,
|
||
containers connected to the same multi-host network but launched from different
|
||
Engines can also communicate in this way.</p>
|
||
|
||
<p>The following example creates a network using the built-in <code>bridge</code> network
|
||
driver and running a container in the created network</p>
|
||
|
||
<pre><code>$ docker network create -d overlay my-net
|
||
$ docker run --net=my-net -itd --name=container3 busybox
|
||
</code></pre>
|
||
|
||
<h3 id="managing-etc-hosts">Managing /etc/hosts</h3>
|
||
|
||
<p>Your container will have lines in <code>/etc/hosts</code> which define the hostname of the
|
||
container itself as well as <code>localhost</code> and a few other common things. The
|
||
<code>--add-host</code> flag can be used to add additional lines to <code>/etc/hosts</code>.</p>
|
||
|
||
<pre><code>$ docker run -it --add-host db-static:86.75.30.9 ubuntu cat /etc/hosts
|
||
172.17.0.22 09d03f76bf2c
|
||
fe00::0 ip6-localnet
|
||
ff00::0 ip6-mcastprefix
|
||
ff02::1 ip6-allnodes
|
||
ff02::2 ip6-allrouters
|
||
127.0.0.1 localhost
|
||
::1 localhost ip6-localhost ip6-loopback
|
||
86.75.30.9 db-static
|
||
</code></pre>
|
||
|
||
<p>If a container is connected to the default bridge network and <code>linked</code>
|
||
with other containers, then the container’s <code>/etc/hosts</code> file is updated
|
||
with the linked container’s name.</p>
|
||
|
||
<p>If the container is connected to user-defined network, the container’s
|
||
<code>/etc/hosts</code> file is updated with names of all other containers in that
|
||
user-defined network.</p>
|
||
|
||
<blockquote>
|
||
<p><strong>Note</strong> Since Docker may live update the container’s <code>/etc/hosts</code> file, there
|
||
may be situations when processes inside the container can end up reading an
|
||
empty or incomplete <code>/etc/hosts</code> file. In most cases, retrying the read again
|
||
should fix the problem.</p>
|
||
</blockquote>
|
||
|
||
<h2 id="restart-policies-restart">Restart policies (–restart)</h2>
|
||
|
||
<p>Using the <code>--restart</code> flag on Docker run you can specify a restart policy for
|
||
how a container should or should not be restarted on exit.</p>
|
||
|
||
<p>When a restart policy is active on a container, it will be shown as either <code>Up</code>
|
||
or <code>Restarting</code> in <a href="../../../engine/reference/commandline/ps/"><code>docker ps</code></a>. It can also be
|
||
useful to use <a href="../../../engine/reference/commandline/events/"><code>docker events</code></a> to see the
|
||
restart policy in effect.</p>
|
||
|
||
<p>Docker supports the following restart policies:</p>
|
||
|
||
<table>
|
||
<thead>
|
||
<tr>
|
||
<th>Policy</th>
|
||
<th>Result</th>
|
||
</tr>
|
||
</thead>
|
||
<tbody>
|
||
<tr>
|
||
<td><strong>no</strong></td>
|
||
<td>
|
||
Do not automatically restart the container when it exits. This is the
|
||
default.
|
||
</td>
|
||
</tr>
|
||
<tr>
|
||
<td>
|
||
<span style="white-space: nowrap">
|
||
<strong>on-failure</strong>[:max-retries]
|
||
</span>
|
||
</td>
|
||
<td>
|
||
Restart only if the container exits with a non-zero exit status.
|
||
Optionally, limit the number of restart retries the Docker
|
||
daemon attempts.
|
||
</td>
|
||
</tr>
|
||
<tr>
|
||
<td><strong>always</strong></td>
|
||
<td>
|
||
Always restart the container regardless of the exit status.
|
||
When you specify always, the Docker daemon will try to restart
|
||
the container indefinitely. The container will also always start
|
||
on daemon startup, regardless of the current state of the container.
|
||
</td>
|
||
</tr>
|
||
<tr>
|
||
<td><strong>unless-stopped</strong></td>
|
||
<td>
|
||
Always restart the container regardless of the exit status, but
|
||
do not start it on daemon startup if the container has been put
|
||
to a stopped state before.
|
||
</td>
|
||
</tr>
|
||
</tbody>
|
||
</table>
|
||
|
||
<p>An ever increasing delay (double the previous delay, starting at 100
|
||
milliseconds) is added before each restart to prevent flooding the server.
|
||
This means the daemon will wait for 100 ms, then 200 ms, 400, 800, 1600,
|
||
and so on until either the <code>on-failure</code> limit is hit, or when you <code>docker stop</code>
|
||
or <code>docker rm -f</code> the container.</p>
|
||
|
||
<p>If a container is successfully restarted (the container is started and runs
|
||
for at least 10 seconds), the delay is reset to its default value of 100 ms.</p>
|
||
|
||
<p>You can specify the maximum amount of times Docker will try to restart the
|
||
container when using the <strong>on-failure</strong> policy. The default is that Docker
|
||
will try forever to restart the container. The number of (attempted) restarts
|
||
for a container can be obtained via <a href="../../../engine/reference/commandline/inspect/"><code>docker inspect</code></a>. For example, to get the number of restarts
|
||
for container “my-container”;</p>
|
||
|
||
<pre><code>$ docker inspect -f "{{ .RestartCount }}" my-container
|
||
# 2
|
||
</code></pre>
|
||
|
||
<p>Or, to get the last time the container was (re)started;</p>
|
||
|
||
<pre><code>$ docker inspect -f "{{ .State.StartedAt }}" my-container
|
||
# 2015-03-04T23:47:07.691840179Z
|
||
</code></pre>
|
||
|
||
<p>You cannot set any restart policy in combination with
|
||
<a href="#clean-up-rm">“clean up (–rm)”</a>. Setting both <code>--restart</code> and <code>--rm</code>
|
||
results in an error.</p>
|
||
|
||
<h3 id="examples">Examples</h3>
|
||
|
||
<pre><code>$ docker run --restart=always redis
|
||
</code></pre>
|
||
|
||
<p>This will run the <code>redis</code> container with a restart policy of <strong>always</strong>
|
||
so that if the container exits, Docker will restart it.</p>
|
||
|
||
<pre><code>$ docker run --restart=on-failure:10 redis
|
||
</code></pre>
|
||
|
||
<p>This will run the <code>redis</code> container with a restart policy of <strong>on-failure</strong>
|
||
and a maximum restart count of 10. If the <code>redis</code> container exits with a
|
||
non-zero exit status more than 10 times in a row Docker will abort trying to
|
||
restart the container. Providing a maximum restart limit is only valid for the
|
||
<strong>on-failure</strong> policy.</p>
|
||
|
||
<h2 id="clean-up-rm">Clean up (–rm)</h2>
|
||
|
||
<p>By default a container’s file system persists even after the container
|
||
exits. This makes debugging a lot easier (since you can inspect the
|
||
final state) and you retain all your data by default. But if you are
|
||
running short-term <strong>foreground</strong> processes, these container file
|
||
systems can really pile up. If instead you’d like Docker to
|
||
<strong>automatically clean up the container and remove the file system when
|
||
the container exits</strong>, you can add the <code>--rm</code> flag:</p>
|
||
|
||
<pre><code>--rm=false: Automatically remove the container when it exits (incompatible with -d)
|
||
</code></pre>
|
||
|
||
<blockquote>
|
||
<p><strong>Note</strong>: When you set the <code>--rm</code> flag, Docker also removes the volumes
|
||
associated with the container when the container is removed. This is similar
|
||
to running <code>docker rm -v my-container</code>.</p>
|
||
</blockquote>
|
||
|
||
<h2 id="security-configuration">Security configuration</h2>
|
||
|
||
<pre><code>--security-opt="label:user:USER" : Set the label user for the container
|
||
--security-opt="label:role:ROLE" : Set the label role for the container
|
||
--security-opt="label:type:TYPE" : Set the label type for the container
|
||
--security-opt="label:level:LEVEL" : Set the label level for the container
|
||
--security-opt="label:disable" : Turn off label confinement for the container
|
||
--security-opt="apparmor:PROFILE" : Set the apparmor profile to be applied
|
||
to the container
|
||
</code></pre>
|
||
|
||
<p>You can override the default labeling scheme for each container by specifying
|
||
the <code>--security-opt</code> flag. For example, you can specify the MCS/MLS level, a
|
||
requirement for MLS systems. Specifying the level in the following command
|
||
allows you to share the same content between containers.</p>
|
||
|
||
<pre><code>$ docker run --security-opt label:level:s0:c100,c200 -i -t fedora bash
|
||
</code></pre>
|
||
|
||
<p>An MLS example might be:</p>
|
||
|
||
<pre><code>$ docker run --security-opt label:level:TopSecret -i -t rhel7 bash
|
||
</code></pre>
|
||
|
||
<p>To disable the security labeling for this container versus running with the
|
||
<code>--permissive</code> flag, use the following command:</p>
|
||
|
||
<pre><code>$ docker run --security-opt label:disable -i -t fedora bash
|
||
</code></pre>
|
||
|
||
<p>If you want a tighter security policy on the processes within a container,
|
||
you can specify an alternate type for the container. You could run a container
|
||
that is only allowed to listen on Apache ports by executing the following
|
||
command:</p>
|
||
|
||
<pre><code>$ docker run --security-opt label:type:svirt_apache_t -i -t centos bash
|
||
</code></pre>
|
||
|
||
<blockquote>
|
||
<p><strong>Note</strong>: You would have to write policy defining a <code>svirt_apache_t</code> type.</p>
|
||
</blockquote>
|
||
|
||
<h2 id="specifying-custom-cgroups">Specifying custom cgroups</h2>
|
||
|
||
<p>Using the <code>--cgroup-parent</code> flag, you can pass a specific cgroup to run a
|
||
container in. This allows you to create and manage cgroups on their own. You can
|
||
define custom resources for those cgroups and put containers under a common
|
||
parent group.</p>
|
||
|
||
<h2 id="runtime-constraints-on-resources">Runtime constraints on resources</h2>
|
||
|
||
<p>The operator can also adjust the performance parameters of the
|
||
container:</p>
|
||
|
||
<table>
|
||
<thead>
|
||
<tr>
|
||
<th>Option</th>
|
||
<th>Description</th>
|
||
</tr>
|
||
</thead>
|
||
|
||
<tbody>
|
||
<tr>
|
||
<td><code>-m</code>, <code>--memory=""</code></td>
|
||
<td>Memory limit (format: <code><number>[<unit>]</code>, where unit = b, k, m or g)</td>
|
||
</tr>
|
||
|
||
<tr>
|
||
<td><code>--memory-swap=""</code></td>
|
||
<td>Total memory limit (memory + swap, format: <code><number>[<unit>]</code>, where unit = b, k, m or g)</td>
|
||
</tr>
|
||
|
||
<tr>
|
||
<td><code>--memory-reservation=""</code></td>
|
||
<td>Memory soft limit (format: <code><number>[<unit>]</code>, where unit = b, k, m or g)</td>
|
||
</tr>
|
||
|
||
<tr>
|
||
<td><code>--kernel-memory=""</code></td>
|
||
<td>Kernel memory limit (format: <code><number>[<unit>]</code>, where unit = b, k, m or g)</td>
|
||
</tr>
|
||
|
||
<tr>
|
||
<td><code>-c</code>, <code>--cpu-shares=0</code></td>
|
||
<td>CPU shares (relative weight)</td>
|
||
</tr>
|
||
|
||
<tr>
|
||
<td><code>--cpu-period=0</code></td>
|
||
<td>Limit the CPU CFS (Completely Fair Scheduler) period</td>
|
||
</tr>
|
||
|
||
<tr>
|
||
<td><code>--cpuset-cpus=""</code></td>
|
||
<td>CPUs in which to allow execution (0-3, 0,1)</td>
|
||
</tr>
|
||
|
||
<tr>
|
||
<td><code>--cpuset-mems=""</code></td>
|
||
<td>Memory nodes (MEMs) in which to allow execution (0-3, 0,1). Only effective on NUMA systems.</td>
|
||
</tr>
|
||
|
||
<tr>
|
||
<td><code>--cpu-quota=0</code></td>
|
||
<td>Limit the CPU CFS (Completely Fair Scheduler) quota</td>
|
||
</tr>
|
||
|
||
<tr>
|
||
<td><code>--blkio-weight=0</code></td>
|
||
<td>Block IO weight (relative weight) accepts a weight value between 10 and 1000.</td>
|
||
</tr>
|
||
|
||
<tr>
|
||
<td><code>--oom-kill-disable=false</code></td>
|
||
<td>Whether to disable OOM Killer for the container or not.</td>
|
||
</tr>
|
||
|
||
<tr>
|
||
<td><code>--memory-swappiness=""</code></td>
|
||
<td>Tune a container’s memory swappiness behavior. Accepts an integer between 0 and 100.</td>
|
||
</tr>
|
||
</tbody>
|
||
</table>
|
||
|
||
<h3 id="user-memory-constraints">User memory constraints</h3>
|
||
|
||
<p>We have four ways to set user memory usage:</p>
|
||
|
||
<table>
|
||
<thead>
|
||
<tr>
|
||
<th>Option</th>
|
||
<th>Result</th>
|
||
</tr>
|
||
</thead>
|
||
<tbody>
|
||
<tr>
|
||
<td class="no-wrap">
|
||
<strong>memory=inf, memory-swap=inf</strong> (default)
|
||
</td>
|
||
<td>
|
||
There is no memory limit for the container. The container can use
|
||
as much memory as needed.
|
||
</td>
|
||
</tr>
|
||
<tr>
|
||
<td class="no-wrap"><strong>memory=L<inf, memory-swap=inf</strong></td>
|
||
<td>
|
||
(specify memory and set memory-swap as <code>-1</code>) The container is
|
||
not allowed to use more than L bytes of memory, but can use as much swap
|
||
as is needed (if the host supports swap memory).
|
||
</td>
|
||
</tr>
|
||
<tr>
|
||
<td class="no-wrap"><strong>memory=L<inf, memory-swap=2*L</strong></td>
|
||
<td>
|
||
(specify memory without memory-swap) The container is not allowed to
|
||
use more than L bytes of memory, swap *plus* memory usage is double
|
||
of that.
|
||
</td>
|
||
</tr>
|
||
<tr>
|
||
<td class="no-wrap">
|
||
<strong>memory=L<inf, memory-swap=S<inf, L<=S</strong>
|
||
</td>
|
||
<td>
|
||
(specify both memory and memory-swap) The container is not allowed to
|
||
use more than L bytes of memory, swap *plus* memory usage is limited
|
||
by S.
|
||
</td>
|
||
</tr>
|
||
</tbody>
|
||
</table>
|
||
|
||
<p>Examples:</p>
|
||
|
||
<pre><code>$ docker run -ti ubuntu:14.04 /bin/bash
|
||
</code></pre>
|
||
|
||
<p>We set nothing about memory, this means the processes in the container can use
|
||
as much memory and swap memory as they need.</p>
|
||
|
||
<pre><code>$ docker run -ti -m 300M --memory-swap -1 ubuntu:14.04 /bin/bash
|
||
</code></pre>
|
||
|
||
<p>We set memory limit and disabled swap memory limit, this means the processes in
|
||
the container can use 300M memory and as much swap memory as they need (if the
|
||
host supports swap memory).</p>
|
||
|
||
<pre><code>$ docker run -ti -m 300M ubuntu:14.04 /bin/bash
|
||
</code></pre>
|
||
|
||
<p>We set memory limit only, this means the processes in the container can use
|
||
300M memory and 300M swap memory, by default, the total virtual memory size
|
||
(–memory-swap) will be set as double of memory, in this case, memory + swap
|
||
would be 2*300M, so processes can use 300M swap memory as well.</p>
|
||
|
||
<pre><code>$ docker run -ti -m 300M --memory-swap 1G ubuntu:14.04 /bin/bash
|
||
</code></pre>
|
||
|
||
<p>We set both memory and swap memory, so the processes in the container can use
|
||
300M memory and 700M swap memory.</p>
|
||
|
||
<p>Memory reservation is a kind of memory soft limit that allows for greater
|
||
sharing of memory. Under normal circumstances, containers can use as much of
|
||
the memory as needed and are constrained only by the hard limits set with the
|
||
<code>-m</code>/<code>--memory</code> option. When memory reservation is set, Docker detects memory
|
||
contention or low memory and forces containers to restrict their consumption to
|
||
a reservation limit.</p>
|
||
|
||
<p>Always set the memory reservation value below the hard limit, otherwise the hard
|
||
limit takes precedence. A reservation of 0 is the same as setting no
|
||
reservation. By default (without reservation set), memory reservation is the
|
||
same as the hard memory limit.</p>
|
||
|
||
<p>Memory reservation is a soft-limit feature and does not guarantee the limit
|
||
won’t be exceeded. Instead, the feature attempts to ensure that, when memory is
|
||
heavily contended for, memory is allocated based on the reservation hints/setup.</p>
|
||
|
||
<p>The following example limits the memory (<code>-m</code>) to 500M and sets the memory
|
||
reservation to 200M.</p>
|
||
|
||
<pre><code class="language-bash">$ docker run -ti -m 500M --memory-reservation 200M ubuntu:14.04 /bin/bash
|
||
</code></pre>
|
||
|
||
<p>Under this configuration, when the container consumes memory more than 200M and
|
||
less than 500M, the next system memory reclaim attempts to shrink container
|
||
memory below 200M.</p>
|
||
|
||
<p>The following example set memory reservation to 1G without a hard memory limit.</p>
|
||
|
||
<pre><code class="language-bash">$ docker run -ti --memory-reservation 1G ubuntu:14.04 /bin/bash
|
||
</code></pre>
|
||
|
||
<p>The container can use as much memory as it needs. The memory reservation setting
|
||
ensures the container doesn’t consume too much memory for long time, because
|
||
every memory reclaim shrinks the container’s consumption to the reservation.</p>
|
||
|
||
<p>By default, kernel kills processes in a container if an out-of-memory (OOM)
|
||
error occurs. To change this behaviour, use the <code>--oom-kill-disable</code> option.
|
||
Only disable the OOM killer on containers where you have also set the
|
||
<code>-m/--memory</code> option. If the <code>-m</code> flag is not set, this can result in the host
|
||
running out of memory and require killing the host’s system processes to free
|
||
memory.</p>
|
||
|
||
<p>The following example limits the memory to 100M and disables the OOM killer for
|
||
this container:</p>
|
||
|
||
<pre><code>$ docker run -ti -m 100M --oom-kill-disable ubuntu:14.04 /bin/bash
|
||
</code></pre>
|
||
|
||
<p>The following example, illustrates a dangerous way to use the flag:</p>
|
||
|
||
<pre><code>$ docker run -ti --oom-kill-disable ubuntu:14.04 /bin/bash
|
||
</code></pre>
|
||
|
||
<p>The container has unlimited memory which can cause the host to run out memory
|
||
and require killing system processes to free memory.</p>
|
||
|
||
<h3 id="kernel-memory-constraints">Kernel memory constraints</h3>
|
||
|
||
<p>Kernel memory is fundamentally different than user memory as kernel memory can’t
|
||
be swapped out. The inability to swap makes it possible for the container to
|
||
block system services by consuming too much kernel memory. Kernel memory includes:</p>
|
||
|
||
<ul>
|
||
<li>stack pages</li>
|
||
<li>slab pages</li>
|
||
<li>sockets memory pressure</li>
|
||
<li>tcp memory pressure</li>
|
||
</ul>
|
||
|
||
<p>You can setup kernel memory limit to constrain these kinds of memory. For example,
|
||
every process consumes some stack pages. By limiting kernel memory, you can
|
||
prevent new processes from being created when the kernel memory usage is too high.</p>
|
||
|
||
<p>Kernel memory is never completely independent of user memory. Instead, you limit
|
||
kernel memory in the context of the user memory limit. Assume “U” is the user memory
|
||
limit and “K” the kernel limit. There are three possible ways to set limits:</p>
|
||
|
||
<table>
|
||
<thead>
|
||
<tr>
|
||
<th>Option</th>
|
||
<th>Result</th>
|
||
</tr>
|
||
</thead>
|
||
<tbody>
|
||
<tr>
|
||
<td class="no-wrap"><strong>U != 0, K = inf</strong> (default)</td>
|
||
<td>
|
||
This is the standard memory limitation mechanism already present before using
|
||
kernel memory. Kernel memory is completely ignored.
|
||
</td>
|
||
</tr>
|
||
<tr>
|
||
<td class="no-wrap"><strong>U != 0, K < U</strong></td>
|
||
<td>
|
||
Kernel memory is a subset of the user memory. This setup is useful in
|
||
deployments where the total amount of memory per-cgroup is overcommitted.
|
||
Overcommitting kernel memory limits is definitely not recommended, since the
|
||
box can still run out of non-reclaimable memory.
|
||
In this case, the you can configure K so that the sum of all groups is
|
||
never greater than the total memory. Then, freely set U at the expense of
|
||
the system's service quality.
|
||
</td>
|
||
</tr>
|
||
<tr>
|
||
<td class="no-wrap"><strong>U != 0, K > U</strong></td>
|
||
<td>
|
||
Since kernel memory charges are also fed to the user counter and reclamation
|
||
is triggered for the container for both kinds of memory. This configuration
|
||
gives the admin a unified view of memory. It is also useful for people
|
||
who just want to track kernel memory usage.
|
||
</td>
|
||
</tr>
|
||
</tbody>
|
||
</table>
|
||
|
||
<p>Examples:</p>
|
||
|
||
<pre><code>$ docker run -ti -m 500M --kernel-memory 50M ubuntu:14.04 /bin/bash
|
||
</code></pre>
|
||
|
||
<p>We set memory and kernel memory, so the processes in the container can use
|
||
500M memory in total, in this 500M memory, it can be 50M kernel memory tops.</p>
|
||
|
||
<pre><code>$ docker run -ti --kernel-memory 50M ubuntu:14.04 /bin/bash
|
||
</code></pre>
|
||
|
||
<p>We set kernel memory without <strong>-m</strong>, so the processes in the container can
|
||
use as much memory as they want, but they can only use 50M kernel memory.</p>
|
||
|
||
<h3 id="swappiness-constraint">Swappiness constraint</h3>
|
||
|
||
<p>By default, a container’s kernel can swap out a percentage of anonymous pages.
|
||
To set this percentage for a container, specify a <code>--memory-swappiness</code> value
|
||
between 0 and 100. A value of 0 turns off anonymous page swapping. A value of
|
||
100 sets all anonymous pages as swappable. By default, if you are not using
|
||
<code>--memory-swappiness</code>, memory swappiness value will be inherited from the parent.</p>
|
||
|
||
<p>For example, you can set:</p>
|
||
|
||
<pre><code>$ docker run -ti --memory-swappiness=0 ubuntu:14.04 /bin/bash
|
||
</code></pre>
|
||
|
||
<p>Setting the <code>--memory-swappiness</code> option is helpful when you want to retain the
|
||
container’s working set and to avoid swapping performance penalties.</p>
|
||
|
||
<h3 id="cpu-share-constraint">CPU share constraint</h3>
|
||
|
||
<p>By default, all containers get the same proportion of CPU cycles. This proportion
|
||
can be modified by changing the container’s CPU share weighting relative
|
||
to the weighting of all other running containers.</p>
|
||
|
||
<p>To modify the proportion from the default of 1024, use the <code>-c</code> or <code>--cpu-shares</code>
|
||
flag to set the weighting to 2 or higher. If 0 is set, the system will ignore the
|
||
value and use the default of 1024.</p>
|
||
|
||
<p>The proportion will only apply when CPU-intensive processes are running.
|
||
When tasks in one container are idle, other containers can use the
|
||
left-over CPU time. The actual amount of CPU time will vary depending on
|
||
the number of containers running on the system.</p>
|
||
|
||
<p>For example, consider three containers, one has a cpu-share of 1024 and
|
||
two others have a cpu-share setting of 512. When processes in all three
|
||
containers attempt to use 100% of CPU, the first container would receive
|
||
50% of the total CPU time. If you add a fourth container with a cpu-share
|
||
of 1024, the first container only gets 33% of the CPU. The remaining containers
|
||
receive 16.5%, 16.5% and 33% of the CPU.</p>
|
||
|
||
<p>On a multi-core system, the shares of CPU time are distributed over all CPU
|
||
cores. Even if a container is limited to less than 100% of CPU time, it can
|
||
use 100% of each individual CPU core.</p>
|
||
|
||
<p>For example, consider a system with more than three cores. If you start one
|
||
container <code>{C0}</code> with <code>-c=512</code> running one process, and another container
|
||
<code>{C1}</code> with <code>-c=1024</code> running two processes, this can result in the following
|
||
division of CPU shares:</p>
|
||
|
||
<pre><code>PID container CPU CPU share
|
||
100 {C0} 0 100% of CPU0
|
||
101 {C1} 1 100% of CPU1
|
||
102 {C1} 2 100% of CPU2
|
||
</code></pre>
|
||
|
||
<h3 id="cpu-period-constraint">CPU period constraint</h3>
|
||
|
||
<p>The default CPU CFS (Completely Fair Scheduler) period is 100ms. We can use
|
||
<code>--cpu-period</code> to set the period of CPUs to limit the container’s CPU usage.
|
||
And usually <code>--cpu-period</code> should work with <code>--cpu-quota</code>.</p>
|
||
|
||
<p>Examples:</p>
|
||
|
||
<pre><code>$ docker run -ti --cpu-period=50000 --cpu-quota=25000 ubuntu:14.04 /bin/bash
|
||
</code></pre>
|
||
|
||
<p>If there is 1 CPU, this means the container can get 50% CPU worth of run-time every 50ms.</p>
|
||
|
||
<p>For more information, see the <a href="https://www.kernel.org/doc/Documentation/scheduler/sched-bwc.txt">CFS documentation on bandwidth limiting</a>.</p>
|
||
|
||
<h3 id="cpuset-constraint">Cpuset constraint</h3>
|
||
|
||
<p>We can set cpus in which to allow execution for containers.</p>
|
||
|
||
<p>Examples:</p>
|
||
|
||
<pre><code>$ docker run -ti --cpuset-cpus="1,3" ubuntu:14.04 /bin/bash
|
||
</code></pre>
|
||
|
||
<p>This means processes in container can be executed on cpu 1 and cpu 3.</p>
|
||
|
||
<pre><code>$ docker run -ti --cpuset-cpus="0-2" ubuntu:14.04 /bin/bash
|
||
</code></pre>
|
||
|
||
<p>This means processes in container can be executed on cpu 0, cpu 1 and cpu 2.</p>
|
||
|
||
<p>We can set mems in which to allow execution for containers. Only effective
|
||
on NUMA systems.</p>
|
||
|
||
<p>Examples:</p>
|
||
|
||
<pre><code>$ docker run -ti --cpuset-mems="1,3" ubuntu:14.04 /bin/bash
|
||
</code></pre>
|
||
|
||
<p>This example restricts the processes in the container to only use memory from
|
||
memory nodes 1 and 3.</p>
|
||
|
||
<pre><code>$ docker run -ti --cpuset-mems="0-2" ubuntu:14.04 /bin/bash
|
||
</code></pre>
|
||
|
||
<p>This example restricts the processes in the container to only use memory from
|
||
memory nodes 0, 1 and 2.</p>
|
||
|
||
<h3 id="cpu-quota-constraint">CPU quota constraint</h3>
|
||
|
||
<p>The <code>--cpu-quota</code> flag limits the container’s CPU usage. The default 0 value
|
||
allows the container to take 100% of a CPU resource (1 CPU). The CFS (Completely Fair
|
||
Scheduler) handles resource allocation for executing processes and is default
|
||
Linux Scheduler used by the kernel. Set this value to 50000 to limit the container
|
||
to 50% of a CPU resource. For multiple CPUs, adjust the <code>--cpu-quota</code> as necessary.
|
||
For more information, see the <a href="https://www.kernel.org/doc/Documentation/scheduler/sched-bwc.txt">CFS documentation on bandwidth limiting</a>.</p>
|
||
|
||
<h3 id="block-io-bandwidth-blkio-constraint">Block IO bandwidth (Blkio) constraint</h3>
|
||
|
||
<p>By default, all containers get the same proportion of block IO bandwidth
|
||
(blkio). This proportion is 500. To modify this proportion, change the
|
||
container’s blkio weight relative to the weighting of all other running
|
||
containers using the <code>--blkio-weight</code> flag.</p>
|
||
|
||
<p>The <code>--blkio-weight</code> flag can set the weighting to a value between 10 to 1000.
|
||
For example, the commands below create two containers with different blkio
|
||
weight:</p>
|
||
|
||
<pre><code>$ docker run -ti --name c1 --blkio-weight 300 ubuntu:14.04 /bin/bash
|
||
$ docker run -ti --name c2 --blkio-weight 600 ubuntu:14.04 /bin/bash
|
||
</code></pre>
|
||
|
||
<p>If you do block IO in the two containers at the same time, by, for example:</p>
|
||
|
||
<pre><code>$ time dd if=/mnt/zerofile of=test.out bs=1M count=1024 oflag=direct
|
||
</code></pre>
|
||
|
||
<p>You’ll find that the proportion of time is the same as the proportion of blkio
|
||
weights of the two containers.</p>
|
||
|
||
<blockquote>
|
||
<p><strong>Note:</strong> The blkio weight setting is only available for direct IO. Buffered IO
|
||
is not currently supported.</p>
|
||
</blockquote>
|
||
|
||
<h2 id="additional-groups">Additional groups</h2>
|
||
|
||
<pre><code>--group-add: Add Linux capabilities
|
||
</code></pre>
|
||
|
||
<p>By default, the docker container process runs with the supplementary groups looked
|
||
up for the specified user. If one wants to add more to that list of groups, then
|
||
one can use this flag:</p>
|
||
|
||
<pre><code>$ docker run -ti --rm --group-add audio --group-add dbus --group-add 777 busybox id
|
||
uid=0(root) gid=0(root) groups=10(wheel),29(audio),81(dbus),777
|
||
</code></pre>
|
||
|
||
<h2 id="runtime-privilege-linux-capabilities-and-lxc-configuration">Runtime privilege, Linux capabilities, and LXC configuration</h2>
|
||
|
||
<pre><code>--cap-add: Add Linux capabilities
|
||
--cap-drop: Drop Linux capabilities
|
||
--privileged=false: Give extended privileges to this container
|
||
--device=[]: Allows you to run devices inside the container without the --privileged flag.
|
||
--lxc-conf=[]: Add custom lxc options
|
||
</code></pre>
|
||
|
||
<p>By default, Docker containers are “unprivileged” and cannot, for
|
||
example, run a Docker daemon inside a Docker container. This is because
|
||
by default a container is not allowed to access any devices, but a
|
||
“privileged” container is given access to all devices (see <a href="https://github.com/docker/docker/blob/master/daemon/execdriver/lxc/lxc_template.go">lxc-template.go</a>
|
||
and documentation on <a href="https://www.kernel.org/doc/Documentation/cgroups/devices.txt">cgroups devices</a>).</p>
|
||
|
||
<p>When the operator executes <code>docker run --privileged</code>, Docker will enable
|
||
to access to all devices on the host as well as set some configuration
|
||
in AppArmor or SELinux to allow the container nearly all the same access to the
|
||
host as processes running outside containers on the host. Additional
|
||
information about running with <code>--privileged</code> is available on the
|
||
<a href="http://blog.docker.com/2013/09/docker-can-now-run-within-docker/">Docker Blog</a>.</p>
|
||
|
||
<p>If you want to limit access to a specific device or devices you can use
|
||
the <code>--device</code> flag. It allows you to specify one or more devices that
|
||
will be accessible within the container.</p>
|
||
|
||
<pre><code>$ docker run --device=/dev/snd:/dev/snd ...
|
||
</code></pre>
|
||
|
||
<p>By default, the container will be able to <code>read</code>, <code>write</code>, and <code>mknod</code> these devices.
|
||
This can be overridden using a third <code>:rwm</code> set of options to each <code>--device</code> flag:</p>
|
||
|
||
<pre><code>$ docker run --device=/dev/sda:/dev/xvdc --rm -it ubuntu fdisk /dev/xvdc
|
||
|
||
Command (m for help): q
|
||
$ docker run --device=/dev/sda:/dev/xvdc:r --rm -it ubuntu fdisk /dev/xvdc
|
||
You will not be able to write the partition table.
|
||
|
||
Command (m for help): q
|
||
|
||
$ docker run --device=/dev/sda:/dev/xvdc:w --rm -it ubuntu fdisk /dev/xvdc
|
||
crash....
|
||
|
||
$ docker run --device=/dev/sda:/dev/xvdc:m --rm -it ubuntu fdisk /dev/xvdc
|
||
fdisk: unable to open /dev/xvdc: Operation not permitted
|
||
</code></pre>
|
||
|
||
<p>In addition to <code>--privileged</code>, the operator can have fine grain control over the
|
||
capabilities using <code>--cap-add</code> and <code>--cap-drop</code>. By default, Docker has a default
|
||
list of capabilities that are kept. The following table lists the Linux capability options which can be added or dropped.</p>
|
||
|
||
<table>
|
||
<thead>
|
||
<tr>
|
||
<th>Capability Key</th>
|
||
<th>Capability Description</th>
|
||
</tr>
|
||
</thead>
|
||
|
||
<tbody>
|
||
<tr>
|
||
<td>SETPCAP</td>
|
||
<td>Modify process capabilities.</td>
|
||
</tr>
|
||
|
||
<tr>
|
||
<td>SYS_MODULE</td>
|
||
<td>Load and unload kernel modules.</td>
|
||
</tr>
|
||
|
||
<tr>
|
||
<td>SYS_RAWIO</td>
|
||
<td>Perform I/O port operations (iopl(2) and ioperm(2)).</td>
|
||
</tr>
|
||
|
||
<tr>
|
||
<td>SYS_PACCT</td>
|
||
<td>Use acct(2), switch process accounting on or off.</td>
|
||
</tr>
|
||
|
||
<tr>
|
||
<td>SYS_ADMIN</td>
|
||
<td>Perform a range of system administration operations.</td>
|
||
</tr>
|
||
|
||
<tr>
|
||
<td>SYS_NICE</td>
|
||
<td>Raise process nice value (nice(2), setpriority(2)) and change the nice value for arbitrary processes.</td>
|
||
</tr>
|
||
|
||
<tr>
|
||
<td>SYS_RESOURCE</td>
|
||
<td>Override resource Limits.</td>
|
||
</tr>
|
||
|
||
<tr>
|
||
<td>SYS_TIME</td>
|
||
<td>Set system clock (settimeofday(2), stime(2), adjtimex(2)); set real-time (hardware) clock.</td>
|
||
</tr>
|
||
|
||
<tr>
|
||
<td>SYS_TTY_CONFIG</td>
|
||
<td>Use vhangup(2); employ various privileged ioctl(2) operations on virtual terminals.</td>
|
||
</tr>
|
||
|
||
<tr>
|
||
<td>MKNOD</td>
|
||
<td>Create special files using mknod(2).</td>
|
||
</tr>
|
||
|
||
<tr>
|
||
<td>AUDIT_WRITE</td>
|
||
<td>Write records to kernel auditing log.</td>
|
||
</tr>
|
||
|
||
<tr>
|
||
<td>AUDIT_CONTROL</td>
|
||
<td>Enable and disable kernel auditing; change auditing filter rules; retrieve auditing status and filtering rules.</td>
|
||
</tr>
|
||
|
||
<tr>
|
||
<td>MAC_OVERRIDE</td>
|
||
<td>Allow MAC configuration or state changes. Implemented for the Smack LSM.</td>
|
||
</tr>
|
||
|
||
<tr>
|
||
<td>MAC_ADMIN</td>
|
||
<td>Override Mandatory Access Control (MAC). Implemented for the Smack Linux Security Module (LSM).</td>
|
||
</tr>
|
||
|
||
<tr>
|
||
<td>NET_ADMIN</td>
|
||
<td>Perform various network-related operations.</td>
|
||
</tr>
|
||
|
||
<tr>
|
||
<td>SYSLOG</td>
|
||
<td>Perform privileged syslog(2) operations.</td>
|
||
</tr>
|
||
|
||
<tr>
|
||
<td>CHOWN</td>
|
||
<td>Make arbitrary changes to file UIDs and GIDs (see chown(2)).</td>
|
||
</tr>
|
||
|
||
<tr>
|
||
<td>NET_RAW</td>
|
||
<td>Use RAW and PACKET sockets.</td>
|
||
</tr>
|
||
|
||
<tr>
|
||
<td>DAC_OVERRIDE</td>
|
||
<td>Bypass file read, write, and execute permission checks.</td>
|
||
</tr>
|
||
|
||
<tr>
|
||
<td>FOWNER</td>
|
||
<td>Bypass permission checks on operations that normally require the file system UID of the process to match the UID of the file.</td>
|
||
</tr>
|
||
|
||
<tr>
|
||
<td>DAC_READ_SEARCH</td>
|
||
<td>Bypass file read permission checks and directory read and execute permission checks.</td>
|
||
</tr>
|
||
|
||
<tr>
|
||
<td>FSETID</td>
|
||
<td>Don’t clear set-user-ID and set-group-ID permission bits when a file is modified.</td>
|
||
</tr>
|
||
|
||
<tr>
|
||
<td>KILL</td>
|
||
<td>Bypass permission checks for sending signals.</td>
|
||
</tr>
|
||
|
||
<tr>
|
||
<td>SETGID</td>
|
||
<td>Make arbitrary manipulations of process GIDs and supplementary GID list.</td>
|
||
</tr>
|
||
|
||
<tr>
|
||
<td>SETUID</td>
|
||
<td>Make arbitrary manipulations of process UIDs.</td>
|
||
</tr>
|
||
|
||
<tr>
|
||
<td>LINUX_IMMUTABLE</td>
|
||
<td>Set the FS_APPEND_FL and FS_IMMUTABLE_FL i-node flags.</td>
|
||
</tr>
|
||
|
||
<tr>
|
||
<td>NET_BIND_SERVICE</td>
|
||
<td>Bind a socket to internet domain privileged ports (port numbers less than 1024).</td>
|
||
</tr>
|
||
|
||
<tr>
|
||
<td>NET_BROADCAST</td>
|
||
<td>Make socket broadcasts, and listen to multicasts.</td>
|
||
</tr>
|
||
|
||
<tr>
|
||
<td>IPC_LOCK</td>
|
||
<td>Lock memory (mlock(2), mlockall(2), mmap(2), shmctl(2)).</td>
|
||
</tr>
|
||
|
||
<tr>
|
||
<td>IPC_OWNER</td>
|
||
<td>Bypass permission checks for operations on System V IPC objects.</td>
|
||
</tr>
|
||
|
||
<tr>
|
||
<td>SYS_CHROOT</td>
|
||
<td>Use chroot(2), change root directory.</td>
|
||
</tr>
|
||
|
||
<tr>
|
||
<td>SYS_PTRACE</td>
|
||
<td>Trace arbitrary processes using ptrace(2).</td>
|
||
</tr>
|
||
|
||
<tr>
|
||
<td>SYS_BOOT</td>
|
||
<td>Use reboot(2) and kexec_load(2), reboot and load a new kernel for later execution.</td>
|
||
</tr>
|
||
|
||
<tr>
|
||
<td>LEASE</td>
|
||
<td>Establish leases on arbitrary files (see fcntl(2)).</td>
|
||
</tr>
|
||
|
||
<tr>
|
||
<td>SETFCAP</td>
|
||
<td>Set file capabilities.</td>
|
||
</tr>
|
||
|
||
<tr>
|
||
<td>WAKE_ALARM</td>
|
||
<td>Trigger something that will wake up the system.</td>
|
||
</tr>
|
||
|
||
<tr>
|
||
<td>BLOCK_SUSPEND</td>
|
||
<td>Employ features that can block system suspend.</td>
|
||
</tr>
|
||
</tbody>
|
||
</table>
|
||
|
||
<p>Further reference information is available on the <a href="http://linux.die.net/man/7/capabilities">capabilities(7) - Linux man page</a></p>
|
||
|
||
<p>Both flags support the value <code>ALL</code>, so if the
|
||
operator wants to have all capabilities but <code>MKNOD</code> they could use:</p>
|
||
|
||
<pre><code>$ docker run --cap-add=ALL --cap-drop=MKNOD ...
|
||
</code></pre>
|
||
|
||
<p>For interacting with the network stack, instead of using <code>--privileged</code> they
|
||
should use <code>--cap-add=NET_ADMIN</code> to modify the network interfaces.</p>
|
||
|
||
<pre><code>$ docker run -t -i --rm ubuntu:14.04 ip link add dummy0 type dummy
|
||
RTNETLINK answers: Operation not permitted
|
||
$ docker run -t -i --rm --cap-add=NET_ADMIN ubuntu:14.04 ip link add dummy0 type dummy
|
||
</code></pre>
|
||
|
||
<p>To mount a FUSE based filesystem, you need to combine both <code>--cap-add</code> and
|
||
<code>--device</code>:</p>
|
||
|
||
<pre><code>$ docker run --rm -it --cap-add SYS_ADMIN sshfs sshfs sven@10.10.10.20:/home/sven /mnt
|
||
fuse: failed to open /dev/fuse: Operation not permitted
|
||
$ docker run --rm -it --device /dev/fuse sshfs sshfs sven@10.10.10.20:/home/sven /mnt
|
||
fusermount: mount failed: Operation not permitted
|
||
$ docker run --rm -it --cap-add SYS_ADMIN --device /dev/fuse sshfs
|
||
# sshfs sven@10.10.10.20:/home/sven /mnt
|
||
The authenticity of host '10.10.10.20 (10.10.10.20)' can't be established.
|
||
ECDSA key fingerprint is 25:34:85:75:25:b0:17:46:05:19:04:93:b5:dd:5f:c6.
|
||
Are you sure you want to continue connecting (yes/no)? yes
|
||
sven@10.10.10.20's password:
|
||
root@30aa0cfaf1b5:/# ls -la /mnt/src/docker
|
||
total 1516
|
||
drwxrwxr-x 1 1000 1000 4096 Dec 4 06:08 .
|
||
drwxrwxr-x 1 1000 1000 4096 Dec 4 11:46 ..
|
||
-rw-rw-r-- 1 1000 1000 16 Oct 8 00:09 .dockerignore
|
||
-rwxrwxr-x 1 1000 1000 464 Oct 8 00:09 .drone.yml
|
||
drwxrwxr-x 1 1000 1000 4096 Dec 4 06:11 .git
|
||
-rw-rw-r-- 1 1000 1000 461 Dec 4 06:08 .gitignore
|
||
....
|
||
</code></pre>
|
||
|
||
<p>If the Docker daemon was started using the <code>lxc</code> exec-driver
|
||
(<code>docker daemon --exec-driver=lxc</code>) then the operator can also specify LXC options
|
||
using one or more <code>--lxc-conf</code> parameters. These can be new parameters or
|
||
override existing parameters from the <a href="https://github.com/docker/docker/blob/master/daemon/execdriver/lxc/lxc_template.go">lxc-template.go</a>.
|
||
Note that in the future, a given host’s docker daemon may not use LXC, so this
|
||
is an implementation-specific configuration meant for operators already
|
||
familiar with using LXC directly.</p>
|
||
|
||
<blockquote>
|
||
<p><strong>Note:</strong>
|
||
If you use <code>--lxc-conf</code> to modify a container’s configuration which is also
|
||
managed by the Docker daemon, then the Docker daemon will not know about this
|
||
modification, and you will need to manage any conflicts yourself. For example,
|
||
you can use <code>--lxc-conf</code> to set a container’s IP address, but this will not be
|
||
reflected in the <code>/etc/hosts</code> file.</p>
|
||
</blockquote>
|
||
|
||
<h2 id="logging-drivers-log-driver">Logging drivers (–log-driver)</h2>
|
||
|
||
<p>The container can have a different logging driver than the Docker daemon. Use
|
||
the <code>--log-driver=VALUE</code> with the <code>docker run</code> command to configure the
|
||
container’s logging driver. The following options are supported:</p>
|
||
|
||
<table>
|
||
<thead>
|
||
<tr>
|
||
<th><code>none</code></th>
|
||
<th>Disables any logging for the container. <code>docker logs</code> won’t be available with this driver.</th>
|
||
</tr>
|
||
</thead>
|
||
|
||
<tbody>
|
||
<tr>
|
||
<td><code>json-file</code></td>
|
||
<td>Default logging driver for Docker. Writes JSON messages to file. No logging options are supported for this driver.</td>
|
||
</tr>
|
||
|
||
<tr>
|
||
<td><code>syslog</code></td>
|
||
<td>Syslog logging driver for Docker. Writes log messages to syslog.</td>
|
||
</tr>
|
||
|
||
<tr>
|
||
<td><code>journald</code></td>
|
||
<td>Journald logging driver for Docker. Writes log messages to <code>journald</code>.</td>
|
||
</tr>
|
||
|
||
<tr>
|
||
<td><code>gelf</code></td>
|
||
<td>Graylog Extended Log Format (GELF) logging driver for Docker. Writes log messages to a GELF endpoint likeGraylog or Logstash.</td>
|
||
</tr>
|
||
|
||
<tr>
|
||
<td><code>fluentd</code></td>
|
||
<td>Fluentd logging driver for Docker. Writes log messages to <code>fluentd</code> (forward input).</td>
|
||
</tr>
|
||
|
||
<tr>
|
||
<td><code>awslogs</code></td>
|
||
<td>Amazon CloudWatch Logs logging driver for Docker. Writes log messages to Amazon CloudWatch Logs</td>
|
||
</tr>
|
||
|
||
<tr>
|
||
<td><code>splunk</code></td>
|
||
<td>Splunk logging driver for Docker. Writes log messages to <code>splunk</code> using Event Http Collector.</td>
|
||
</tr>
|
||
</tbody>
|
||
</table>
|
||
|
||
<p>The <code>docker logs</code> command is available only for the <code>json-file</code> and <code>journald</code>
|
||
logging drivers. For detailed information on working with logging drivers, see
|
||
<a href="../../../engine/reference/logging/overview/">Configure a logging driver</a>.</p>
|
||
|
||
<h2 id="overriding-dockerfile-image-defaults">Overriding Dockerfile image defaults</h2>
|
||
|
||
<p>When a developer builds an image from a <a href="../../../engine/reference/builder/"><em>Dockerfile</em></a>
|
||
or when she commits it, the developer can set a number of default parameters
|
||
that take effect when the image starts up as a container.</p>
|
||
|
||
<p>Four of the Dockerfile commands cannot be overridden at runtime: <code>FROM</code>,
|
||
<code>MAINTAINER</code>, <code>RUN</code>, and <code>ADD</code>. Everything else has a corresponding override
|
||
in <code>docker run</code>. We’ll go through what the developer might have set in each
|
||
Dockerfile instruction and how the operator can override that setting.</p>
|
||
|
||
<ul>
|
||
<li><a href="#cmd-default-command-or-options">CMD (Default Command or Options)</a></li>
|
||
<li><a href="#entrypoint-default-command-to-execute-at-runtime">ENTRYPOINT (Default Command to Execute at Runtime)</a></li>
|
||
<li><a href="#expose-incoming-ports">EXPOSE (Incoming Ports)</a></li>
|
||
<li><a href="#env-environment-variables">ENV (Environment Variables)</a></li>
|
||
<li><a href="#volume-shared-filesystems">VOLUME (Shared Filesystems)</a></li>
|
||
<li><a href="#user">USER</a></li>
|
||
<li><a href="#workdir">WORKDIR</a></li>
|
||
</ul>
|
||
|
||
<h3 id="cmd-default-command-or-options">CMD (default command or options)</h3>
|
||
|
||
<p>Recall the optional <code>COMMAND</code> in the Docker
|
||
commandline:</p>
|
||
|
||
<pre><code>$ docker run [OPTIONS] IMAGE[:TAG|@DIGEST] [COMMAND] [ARG...]
|
||
</code></pre>
|
||
|
||
<p>This command is optional because the person who created the <code>IMAGE</code> may
|
||
have already provided a default <code>COMMAND</code> using the Dockerfile <code>CMD</code>
|
||
instruction. As the operator (the person running a container from the
|
||
image), you can override that <code>CMD</code> instruction just by specifying a new
|
||
<code>COMMAND</code>.</p>
|
||
|
||
<p>If the image also specifies an <code>ENTRYPOINT</code> then the <code>CMD</code> or <code>COMMAND</code>
|
||
get appended as arguments to the <code>ENTRYPOINT</code>.</p>
|
||
|
||
<h3 id="entrypoint-default-command-to-execute-at-runtime">ENTRYPOINT (default command to execute at runtime)</h3>
|
||
|
||
<pre><code>--entrypoint="": Overwrite the default entrypoint set by the image
|
||
</code></pre>
|
||
|
||
<p>The <code>ENTRYPOINT</code> of an image is similar to a <code>COMMAND</code> because it
|
||
specifies what executable to run when the container starts, but it is
|
||
(purposely) more difficult to override. The <code>ENTRYPOINT</code> gives a
|
||
container its default nature or behavior, so that when you set an
|
||
<code>ENTRYPOINT</code> you can run the container <em>as if it were that binary</em>,
|
||
complete with default options, and you can pass in more options via the
|
||
<code>COMMAND</code>. But, sometimes an operator may want to run something else
|
||
inside the container, so you can override the default <code>ENTRYPOINT</code> at
|
||
runtime by using a string to specify the new <code>ENTRYPOINT</code>. Here is an
|
||
example of how to run a shell in a container that has been set up to
|
||
automatically run something else (like <code>/usr/bin/redis-server</code>):</p>
|
||
|
||
<pre><code>$ docker run -i -t --entrypoint /bin/bash example/redis
|
||
</code></pre>
|
||
|
||
<p>or two examples of how to pass more parameters to that ENTRYPOINT:</p>
|
||
|
||
<pre><code>$ docker run -i -t --entrypoint /bin/bash example/redis -c ls -l
|
||
$ docker run -i -t --entrypoint /usr/bin/redis-cli example/redis --help
|
||
</code></pre>
|
||
|
||
<h3 id="expose-incoming-ports">EXPOSE (incoming ports)</h3>
|
||
|
||
<p>The following <code>run</code> command options work with container networking:</p>
|
||
|
||
<pre><code>--expose=[]: Expose a port or a range of ports inside the container.
|
||
These are additional to those exposed by the `EXPOSE` instruction
|
||
-P=false : Publish all exposed ports to the host interfaces
|
||
-p=[] : Publish a container᾿s port or a range of ports to the host
|
||
format: ip:hostPort:containerPort | ip::containerPort | hostPort:containerPort | containerPort
|
||
Both hostPort and containerPort can be specified as a
|
||
range of ports. When specifying ranges for both, the
|
||
number of container ports in the range must match the
|
||
number of host ports in the range, for example:
|
||
-p 1234-1236:1234-1236/tcp
|
||
|
||
When specifying a range for hostPort only, the
|
||
containerPort must not be a range. In this case the
|
||
container port is published somewhere within the
|
||
specified hostPort range. (e.g., `-p 1234-1236:1234/tcp`)
|
||
|
||
(use 'docker port' to see the actual mapping)
|
||
|
||
--link="" : Add link to another container (<name or id>:alias or <name or id>)
|
||
</code></pre>
|
||
|
||
<p>With the exception of the <code>EXPOSE</code> directive, an image developer hasn’t
|
||
got much control over networking. The <code>EXPOSE</code> instruction defines the
|
||
initial incoming ports that provide services. These ports are available
|
||
to processes inside the container. An operator can use the <code>--expose</code>
|
||
option to add to the exposed ports.</p>
|
||
|
||
<p>To expose a container’s internal port, an operator can start the
|
||
container with the <code>-P</code> or <code>-p</code> flag. The exposed port is accessible on
|
||
the host and the ports are available to any client that can reach the
|
||
host.</p>
|
||
|
||
<p>The <code>-P</code> option publishes all the ports to the host interfaces. Docker
|
||
binds each exposed port to a random port on the host. The range of
|
||
ports are within an <em>ephemeral port range</em> defined by
|
||
<code>/proc/sys/net/ipv4/ip_local_port_range</code>. Use the <code>-p</code> flag to
|
||
explicitly map a single port or range of ports.</p>
|
||
|
||
<p>The port number inside the container (where the service listens) does
|
||
not need to match the port number exposed on the outside of the
|
||
container (where clients connect). For example, inside the container an
|
||
HTTP service is listening on port 80 (and so the image developer
|
||
specifies <code>EXPOSE 80</code> in the Dockerfile). At runtime, the port might be
|
||
bound to 42800 on the host. To find the mapping between the host ports
|
||
and the exposed ports, use <code>docker port</code>.</p>
|
||
|
||
<p>If the operator uses <code>--link</code> when starting a new client container, then the
|
||
client container can access the exposed port via a private networking interface.
|
||
Linking is a legacy feature that is only supported on the default bridge
|
||
network. You should prefer the Docker networks feature instead. For more
|
||
information on this feature, see the <a href="../../../engine/userguide/networking/"><em>Docker network
|
||
overview</em>””</a>).</p>
|
||
|
||
<h3 id="env-environment-variables">ENV (environment variables)</h3>
|
||
|
||
<p>When a new container is created, Docker will set the following environment
|
||
variables automatically:</p>
|
||
|
||
<table>
|
||
<tr>
|
||
<th>Variable</th>
|
||
<th>Value</th>
|
||
</tr>
|
||
<tr>
|
||
<td><code>HOME</code></td>
|
||
<td>
|
||
Set based on the value of <code>USER</code>
|
||
</td>
|
||
</tr>
|
||
<tr>
|
||
<td><code>HOSTNAME</code></td>
|
||
<td>
|
||
The hostname associated with the container
|
||
</td>
|
||
</tr>
|
||
<tr>
|
||
<td><code>PATH</code></td>
|
||
<td>
|
||
Includes popular directories, such as :<br>
|
||
<code>/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin</code>
|
||
</td>
|
||
<tr>
|
||
<td><code>TERM</code></td>
|
||
<td><code>xterm</code> if the container is allocated a pseudo-TTY</td>
|
||
</tr>
|
||
</table>
|
||
|
||
<p>Additionally, the operator can <strong>set any environment variable</strong> in the
|
||
container by using one or more <code>-e</code> flags, even overriding those mentioned
|
||
above, or already defined by the developer with a Dockerfile <code>ENV</code>:</p>
|
||
|
||
<pre><code>$ docker run -e "deep=purple" --rm ubuntu /bin/bash -c export
|
||
declare -x HOME="/"
|
||
declare -x HOSTNAME="85bc26a0e200"
|
||
declare -x OLDPWD
|
||
declare -x PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
|
||
declare -x PWD="/"
|
||
declare -x SHLVL="1"
|
||
declare -x container="lxc"
|
||
declare -x deep="purple"
|
||
</code></pre>
|
||
|
||
<p>Similarly the operator can set the <strong>hostname</strong> with <code>-h</code>.</p>
|
||
|
||
<h3 id="volume-shared-filesystems">VOLUME (shared filesystems)</h3>
|
||
|
||
<pre><code>-v=[]: Create a bind mount with: [host-dir:]container-dir[:<options>], where
|
||
options are comma delimited and selected from [rw|ro] and [z|Z].
|
||
If 'host-dir' is missing, then docker creates a new volume.
|
||
If neither 'rw' or 'ro' is specified then the volume is mounted
|
||
in read-write mode.
|
||
--volumes-from="": Mount all volumes from the given container(s)
|
||
</code></pre>
|
||
|
||
<blockquote>
|
||
<p><strong>Note</strong>:
|
||
The auto-creation of the host path has been <a href="../../../engine/misc/deprecated/#auto-creating-missing-host-paths-for-bind-mounts"><em>deprecated</em></a>.</p>
|
||
</blockquote>
|
||
|
||
<p>The volumes commands are complex enough to have their own documentation
|
||
in section <a href="../../../engine/userguide/dockervolumes/"><em>Managing data in
|
||
containers</em></a>. A developer can define
|
||
one or more <code>VOLUME</code>’s associated with an image, but only the operator
|
||
can give access from one container to another (or from a container to a
|
||
volume mounted on the host).</p>
|
||
|
||
<p>The <code>container-dir</code> must always be an absolute path such as <code>/src/docs</code>.
|
||
The <code>host-dir</code> can either be an absolute path or a <code>name</code> value. If you
|
||
supply an absolute path for the <code>host-dir</code>, Docker bind-mounts to the path
|
||
you specify. If you supply a <code>name</code>, Docker creates a named volume by that <code>name</code>.</p>
|
||
|
||
<p>A <code>name</code> value must start with start with an alphanumeric character,
|
||
followed by <code>a-z0-9</code>, <code>_</code> (underscore), <code>.</code> (period) or <code>-</code> (hyphen).
|
||
An absolute path starts with a <code>/</code> (forward slash).</p>
|
||
|
||
<p>For example, you can specify either <code>/foo</code> or <code>foo</code> for a <code>host-dir</code> value.
|
||
If you supply the <code>/foo</code> value, Docker creates a bind-mount. If you supply
|
||
the <code>foo</code> specification, Docker creates a named volume.</p>
|
||
|
||
<h3 id="user">USER</h3>
|
||
|
||
<p><code>root</code> (id = 0) is the default user within a container. The image developer can
|
||
create additional users. Those users are accessible by name. When passing a numeric
|
||
ID, the user does not have to exist in the container.</p>
|
||
|
||
<p>The developer can set a default user to run the first process with the
|
||
Dockerfile <code>USER</code> instruction. When starting a container, the operator can override
|
||
the <code>USER</code> instruction by passing the <code>-u</code> option.</p>
|
||
|
||
<pre><code>-u="": Username or UID
|
||
</code></pre>
|
||
|
||
<blockquote>
|
||
<p><strong>Note:</strong> if you pass a numeric uid, it must be in the range of 0-2147483647.</p>
|
||
</blockquote>
|
||
|
||
<h3 id="workdir">WORKDIR</h3>
|
||
|
||
<p>The default working directory for running binaries within a container is the
|
||
root directory (<code>/</code>), but the developer can set a different default with the
|
||
Dockerfile <code>WORKDIR</code> command. The operator can override this with:</p>
|
||
|
||
<pre><code>-w="": Working directory inside the container
|
||
</code></pre>
|
||
|
||
</article>
|
||
</section>
|
||
</div>
|
||
<div id="toc" class="large-3 columns toc compact">
|
||
On this page:
|
||
<nav id="TableOfContents">
|
||
<ul>
|
||
<li><a href="#docker-run-reference">Docker run reference</a>
|
||
<ul>
|
||
<li><a href="#general-form">General form</a></li>
|
||
<li><a href="#operator-exclusive-options">Operator exclusive options</a></li>
|
||
<li><a href="#detached-vs-foreground">Detached vs foreground</a>
|
||
<ul>
|
||
<li><a href="#detached-d">Detached (-d)</a></li>
|
||
<li><a href="#foreground">Foreground</a></li>
|
||
</ul></li>
|
||
<li><a href="#container-identification">Container identification</a>
|
||
<ul>
|
||
<li><a href="#name-name">Name (–name)</a></li>
|
||
<li><a href="#pid-equivalent">PID equivalent</a></li>
|
||
<li><a href="#image-tag">Image[:tag]</a></li>
|
||
<li><a href="#image-digest">Image[@digest]</a></li>
|
||
</ul></li>
|
||
<li><a href="#pid-settings-pid">PID settings (–pid)</a></li>
|
||
<li><a href="#uts-settings-uts">UTS settings (–uts)</a></li>
|
||
<li><a href="#ipc-settings-ipc">IPC settings (–ipc)</a></li>
|
||
<li><a href="#network-settings">Network settings</a>
|
||
<ul>
|
||
<li>
|
||
<ul>
|
||
<li><a href="#network-none">Network: none</a></li>
|
||
<li><a href="#network-bridge">Network: bridge</a></li>
|
||
<li><a href="#network-host">Network: host</a></li>
|
||
<li><a href="#network-container">Network: container</a></li>
|
||
<li><a href="#user-defined-network">User-defined network</a></li>
|
||
</ul></li>
|
||
<li><a href="#managing-etc-hosts">Managing /etc/hosts</a></li>
|
||
</ul></li>
|
||
<li><a href="#restart-policies-restart">Restart policies (–restart)</a>
|
||
<ul>
|
||
<li><a href="#examples">Examples</a></li>
|
||
</ul></li>
|
||
<li><a href="#clean-up-rm">Clean up (–rm)</a></li>
|
||
<li><a href="#security-configuration">Security configuration</a></li>
|
||
<li><a href="#specifying-custom-cgroups">Specifying custom cgroups</a></li>
|
||
<li><a href="#runtime-constraints-on-resources">Runtime constraints on resources</a>
|
||
<ul>
|
||
<li><a href="#user-memory-constraints">User memory constraints</a></li>
|
||
<li><a href="#kernel-memory-constraints">Kernel memory constraints</a></li>
|
||
<li><a href="#swappiness-constraint">Swappiness constraint</a></li>
|
||
<li><a href="#cpu-share-constraint">CPU share constraint</a></li>
|
||
<li><a href="#cpu-period-constraint">CPU period constraint</a></li>
|
||
<li><a href="#cpuset-constraint">Cpuset constraint</a></li>
|
||
<li><a href="#cpu-quota-constraint">CPU quota constraint</a></li>
|
||
<li><a href="#block-io-bandwidth-blkio-constraint">Block IO bandwidth (Blkio) constraint</a></li>
|
||
</ul></li>
|
||
<li><a href="#additional-groups">Additional groups</a></li>
|
||
<li><a href="#runtime-privilege-linux-capabilities-and-lxc-configuration">Runtime privilege, Linux capabilities, and LXC configuration</a></li>
|
||
<li><a href="#logging-drivers-log-driver">Logging drivers (–log-driver)</a></li>
|
||
<li><a href="#overriding-dockerfile-image-defaults">Overriding Dockerfile image defaults</a>
|
||
<ul>
|
||
<li><a href="#cmd-default-command-or-options">CMD (default command or options)</a></li>
|
||
<li><a href="#entrypoint-default-command-to-execute-at-runtime">ENTRYPOINT (default command to execute at runtime)</a></li>
|
||
<li><a href="#expose-incoming-ports">EXPOSE (incoming ports)</a></li>
|
||
<li><a href="#env-environment-variables">ENV (environment variables)</a></li>
|
||
<li><a href="#volume-shared-filesystems">VOLUME (shared filesystems)</a></li>
|
||
<li><a href="#user">USER</a></li>
|
||
<li><a href="#workdir">WORKDIR</a></li>
|
||
</ul></li>
|
||
</ul></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>
|
||
|