├── packaging ├── debian │ ├── compat │ ├── docs │ ├── source │ │ └── format │ ├── rules │ ├── maintainer.rst │ ├── README.Debian │ ├── control │ ├── Vagrantfile │ ├── copyright │ ├── changelog │ ├── lxc-docker.init │ └── Makefile ├── ubuntu │ ├── compat │ ├── docs │ ├── source │ │ └── format │ ├── lxc-docker.prerm │ ├── lxc-docker.postinst │ ├── docker.upstart │ ├── rules │ ├── control │ ├── parse_changelog.py │ ├── Vagrantfile │ ├── README.ubuntu │ ├── maintainer.ubuntu │ └── Makefile ├── MAINTAINERS ├── README.rst └── archlinux │ └── README.archlinux ├── auth ├── MAINTAINERS └── auth_test.go ├── docs ├── theme │ ├── docker │ │ ├── static │ │ │ ├── css │ │ │ │ └── variables.css │ │ │ ├── js │ │ │ │ ├── main.js │ │ │ │ ├── docs.js │ │ │ │ ├── jquery.ba-urlinternal.min.js │ │ │ │ └── jquery.ba-bbq.min.js │ │ │ ├── favicon.png │ │ │ └── img │ │ │ │ ├── fork-us.png │ │ │ │ ├── footer-links.png │ │ │ │ ├── hiring_graphic.png │ │ │ │ ├── docker-letters-logo.gif │ │ │ │ ├── docker_letters_500px.png │ │ │ │ ├── glyphicons-halflings.png │ │ │ │ ├── docs-splash-colhead320.png │ │ │ │ └── glyphicons-halflings-white.png │ │ ├── theme.conf │ │ └── redirect_home.html │ └── MAINTAINERS ├── website │ ├── static │ ├── dotcloud.yml │ ├── MAINTAINERS │ └── nginx.conf ├── requirements.txt ├── sources │ ├── api │ │ ├── MAINTAINERS │ │ ├── index.rst │ │ └── README.md │ ├── concepts │ │ ├── images │ │ │ └── lego_docker.jpg │ │ └── index.rst │ ├── installation │ │ ├── images │ │ │ └── win │ │ │ │ ├── _01.gif │ │ │ │ ├── _02.gif │ │ │ │ ├── _06.gif │ │ │ │ ├── putty.gif │ │ │ │ ├── cygwin.gif │ │ │ │ ├── putty_2.gif │ │ │ │ ├── run_02_.gif │ │ │ │ ├── run_03.gif │ │ │ │ ├── run_04.gif │ │ │ │ └── ssh-config.gif │ │ ├── index.rst │ │ ├── upgrading.rst │ │ ├── binaries.rst │ │ ├── vagrant.rst │ │ ├── archlinux.rst │ │ ├── amazon.rst │ │ ├── rackspace.rst │ │ ├── ubuntulinux.rst │ │ └── kernel.rst │ ├── static_files │ │ ├── docker_pull_chart.png │ │ ├── docker_push_chart.png │ │ └── README.md │ ├── terms │ │ ├── images │ │ │ ├── docker-filesystems-debian.png │ │ │ ├── docker-filesystems-generic.png │ │ │ ├── docker-filesystems-busyboxrw.png │ │ │ ├── docker-filesystems-debianrw.png │ │ │ ├── docker-filesystems-multiroot.png │ │ │ └── docker-filesystems-multilayer.png │ │ ├── index.rst │ │ └── fundamentals.rst │ ├── commandline │ │ ├── command │ │ │ ├── images │ │ │ │ └── docker_images.gif │ │ │ ├── version.rst │ │ │ ├── rmi.rst │ │ │ ├── rm.rst │ │ │ ├── stop.rst │ │ │ ├── start.rst │ │ │ ├── kill.rst │ │ │ ├── info.rst │ │ │ ├── logs.rst │ │ │ ├── attach.rst │ │ │ ├── restart.rst │ │ │ ├── history.rst │ │ │ ├── tag.rst │ │ │ ├── login.rst │ │ │ ├── diff.rst │ │ │ ├── inspect.rst │ │ │ ├── ps.rst │ │ │ ├── export.rst │ │ │ ├── push.rst │ │ │ ├── pull.rst │ │ │ ├── wait.rst │ │ │ ├── port.rst │ │ │ ├── search.rst │ │ │ ├── images.rst │ │ │ ├── run.rst │ │ │ ├── commit.rst │ │ │ ├── import.rst │ │ │ └── build.rst │ │ ├── index.rst │ │ └── cli.rst │ ├── examples │ │ ├── example_header.inc │ │ ├── index.rst │ │ ├── running_examples.rst │ │ ├── hello_world.rst │ │ ├── couchdb_data_volumes.rst │ │ ├── running_redis_service.rst │ │ ├── hello_world_daemon.rst │ │ ├── running_ssh_service.rst │ │ └── python_web_app.rst │ ├── contributing │ │ ├── index.rst │ │ ├── contributing.rst │ │ └── devenvironment.rst │ ├── use │ │ ├── index.rst │ │ ├── port_redirection.rst │ │ ├── puppet.rst │ │ ├── workingwithrepository.rst │ │ └── basics.rst │ ├── toctree.rst │ └── faq.rst ├── MAINTAINERS └── README.md ├── testing ├── MAINTAINERS ├── buildbot │ ├── README.rst │ ├── requirements.txt │ ├── buildbot.conf │ ├── setup.sh │ └── master.cfg ├── README.rst └── Vagrantfile ├── contrib ├── MAINTAINERS ├── vagrant-docker │ └── README.md ├── README ├── mkimage-busybox.sh ├── mkimage-debian.sh ├── install.sh └── crashTest.go ├── hack ├── dockerbuilder │ ├── MAINTAINERS │ ├── dockerbuilder │ └── Dockerfile ├── environment │ ├── README.rst │ ├── requirements.txt │ ├── bash_profile │ ├── buildbot.conf │ ├── post-commit │ ├── setup.sh │ └── master.cfg ├── infrastructure │ ├── MAINTAINERS │ └── README.md ├── allmaintainers.sh ├── README.rst ├── PRINCIPLES.md ├── fmt-check.hook ├── getmaintainer.sh └── Vagrantfile ├── term ├── MAINTAINERS ├── termios_linux.go ├── termios_darwin.go └── term.go ├── registry └── MAINTAINERS ├── mount_darwin.go ├── mount_linux.go ├── MAINTAINERS ├── utils ├── uname_darwin.go └── uname_linux.go ├── .gitignore ├── NOTICE ├── state.go ├── .mailmap ├── tags_test.go ├── mount.go ├── FIXME ├── api_params.go ├── utils.go ├── sysinit.go ├── Makefile ├── changes.go ├── archive_test.go ├── AUTHORS ├── Vagrantfile ├── server_test.go ├── lxc_template.go └── docker └── docker.go /packaging/debian/compat: -------------------------------------------------------------------------------- 1 | 9 2 | -------------------------------------------------------------------------------- /packaging/ubuntu/compat: -------------------------------------------------------------------------------- 1 | 8 2 | -------------------------------------------------------------------------------- /packaging/debian/docs: -------------------------------------------------------------------------------- 1 | README.md 2 | -------------------------------------------------------------------------------- /packaging/ubuntu/docs: -------------------------------------------------------------------------------- 1 | README.md 2 | -------------------------------------------------------------------------------- /auth/MAINTAINERS: -------------------------------------------------------------------------------- 1 | ../registry/MAINTAINERS -------------------------------------------------------------------------------- /docs/theme/docker/static/css/variables.css: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/theme/docker/static/js/main.js: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /docs/website/static: -------------------------------------------------------------------------------- 1 | ../theme/docker/static -------------------------------------------------------------------------------- /docs/website/dotcloud.yml: -------------------------------------------------------------------------------- 1 | www: 2 | type: static -------------------------------------------------------------------------------- /packaging/debian/source/format: -------------------------------------------------------------------------------- 1 | 3.0 (quilt) 2 | -------------------------------------------------------------------------------- /packaging/ubuntu/source/format: -------------------------------------------------------------------------------- 1 | 3.0 (quilt) 2 | -------------------------------------------------------------------------------- /testing/MAINTAINERS: -------------------------------------------------------------------------------- 1 | Daniel Mizyrycki 2 | -------------------------------------------------------------------------------- /docs/theme/MAINTAINERS: -------------------------------------------------------------------------------- 1 | Thatcher Penskens 2 | -------------------------------------------------------------------------------- /packaging/MAINTAINERS: -------------------------------------------------------------------------------- 1 | Daniel Mizyrycki 2 | -------------------------------------------------------------------------------- /contrib/MAINTAINERS: -------------------------------------------------------------------------------- 1 | # Maintainer wanted! Enroll on #docker@freenode 2 | -------------------------------------------------------------------------------- /docs/requirements.txt: -------------------------------------------------------------------------------- 1 | Sphinx==1.1.3 2 | sphinxcontrib-httpdomain==1.1.8 -------------------------------------------------------------------------------- /docs/sources/api/MAINTAINERS: -------------------------------------------------------------------------------- 1 | Solomon Hykes 2 | -------------------------------------------------------------------------------- /docs/website/MAINTAINERS: -------------------------------------------------------------------------------- 1 | Thatcher Penskens 2 | -------------------------------------------------------------------------------- /hack/dockerbuilder/MAINTAINERS: -------------------------------------------------------------------------------- 1 | Daniel Mizyrycki 2 | -------------------------------------------------------------------------------- /hack/environment/README.rst: -------------------------------------------------------------------------------- 1 | Files used to setup the developer virtual machine 2 | -------------------------------------------------------------------------------- /docs/MAINTAINERS: -------------------------------------------------------------------------------- 1 | Andy Rothfusz 2 | Ken Cochrane 3 | -------------------------------------------------------------------------------- /packaging/ubuntu/lxc-docker.prerm: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Stop docker 4 | /sbin/stop docker 5 | -------------------------------------------------------------------------------- /packaging/ubuntu/lxc-docker.postinst: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Start docker 4 | /sbin/start docker 5 | -------------------------------------------------------------------------------- /term/MAINTAINERS: -------------------------------------------------------------------------------- 1 | Guillaume Charmes 2 | Solomon Hykes 3 | -------------------------------------------------------------------------------- /testing/buildbot/README.rst: -------------------------------------------------------------------------------- 1 | Buildbot configuration and setup files (except Vagrantfile located on ..) 2 | -------------------------------------------------------------------------------- /hack/infrastructure/MAINTAINERS: -------------------------------------------------------------------------------- 1 | Ken Cochrane 2 | Jerome Petazzoni 3 | -------------------------------------------------------------------------------- /docs/theme/docker/static/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fcoury/docker/master/docs/theme/docker/static/favicon.png -------------------------------------------------------------------------------- /docs/theme/docker/static/img/fork-us.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fcoury/docker/master/docs/theme/docker/static/img/fork-us.png -------------------------------------------------------------------------------- /registry/MAINTAINERS: -------------------------------------------------------------------------------- 1 | Sam Alba 2 | Joffrey Fuhrer 3 | Ken Cochrane 4 | -------------------------------------------------------------------------------- /docs/sources/concepts/images/lego_docker.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fcoury/docker/master/docs/sources/concepts/images/lego_docker.jpg -------------------------------------------------------------------------------- /docs/sources/installation/images/win/_01.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fcoury/docker/master/docs/sources/installation/images/win/_01.gif -------------------------------------------------------------------------------- /docs/sources/installation/images/win/_02.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fcoury/docker/master/docs/sources/installation/images/win/_02.gif -------------------------------------------------------------------------------- /docs/sources/installation/images/win/_06.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fcoury/docker/master/docs/sources/installation/images/win/_06.gif -------------------------------------------------------------------------------- /docs/sources/installation/images/win/putty.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fcoury/docker/master/docs/sources/installation/images/win/putty.gif -------------------------------------------------------------------------------- /docs/theme/docker/static/img/footer-links.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fcoury/docker/master/docs/theme/docker/static/img/footer-links.png -------------------------------------------------------------------------------- /docs/sources/installation/images/win/cygwin.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fcoury/docker/master/docs/sources/installation/images/win/cygwin.gif -------------------------------------------------------------------------------- /docs/sources/installation/images/win/putty_2.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fcoury/docker/master/docs/sources/installation/images/win/putty_2.gif -------------------------------------------------------------------------------- /docs/sources/installation/images/win/run_02_.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fcoury/docker/master/docs/sources/installation/images/win/run_02_.gif -------------------------------------------------------------------------------- /docs/sources/installation/images/win/run_03.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fcoury/docker/master/docs/sources/installation/images/win/run_03.gif -------------------------------------------------------------------------------- /docs/sources/installation/images/win/run_04.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fcoury/docker/master/docs/sources/installation/images/win/run_04.gif -------------------------------------------------------------------------------- /docs/sources/static_files/docker_pull_chart.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fcoury/docker/master/docs/sources/static_files/docker_pull_chart.png -------------------------------------------------------------------------------- /docs/sources/static_files/docker_push_chart.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fcoury/docker/master/docs/sources/static_files/docker_push_chart.png -------------------------------------------------------------------------------- /docs/theme/docker/static/img/hiring_graphic.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fcoury/docker/master/docs/theme/docker/static/img/hiring_graphic.png -------------------------------------------------------------------------------- /packaging/debian/rules: -------------------------------------------------------------------------------- 1 | #!/usr/bin/make -f 2 | # -*- makefile -*- 3 | 4 | #export DH_VERBOSE=1 5 | 6 | %: 7 | dh ${@} --with autotools_dev 8 | -------------------------------------------------------------------------------- /docs/sources/installation/images/win/ssh-config.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fcoury/docker/master/docs/sources/installation/images/win/ssh-config.gif -------------------------------------------------------------------------------- /docs/theme/docker/static/img/docker-letters-logo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fcoury/docker/master/docs/theme/docker/static/img/docker-letters-logo.gif -------------------------------------------------------------------------------- /docs/theme/docker/static/img/docker_letters_500px.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fcoury/docker/master/docs/theme/docker/static/img/docker_letters_500px.png -------------------------------------------------------------------------------- /docs/theme/docker/static/img/glyphicons-halflings.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fcoury/docker/master/docs/theme/docker/static/img/glyphicons-halflings.png -------------------------------------------------------------------------------- /docs/sources/terms/images/docker-filesystems-debian.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fcoury/docker/master/docs/sources/terms/images/docker-filesystems-debian.png -------------------------------------------------------------------------------- /docs/sources/terms/images/docker-filesystems-generic.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fcoury/docker/master/docs/sources/terms/images/docker-filesystems-generic.png -------------------------------------------------------------------------------- /docs/theme/docker/static/img/docs-splash-colhead320.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fcoury/docker/master/docs/theme/docker/static/img/docs-splash-colhead320.png -------------------------------------------------------------------------------- /docs/sources/commandline/command/images/docker_images.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fcoury/docker/master/docs/sources/commandline/command/images/docker_images.gif -------------------------------------------------------------------------------- /docs/sources/terms/images/docker-filesystems-busyboxrw.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fcoury/docker/master/docs/sources/terms/images/docker-filesystems-busyboxrw.png -------------------------------------------------------------------------------- /docs/sources/terms/images/docker-filesystems-debianrw.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fcoury/docker/master/docs/sources/terms/images/docker-filesystems-debianrw.png -------------------------------------------------------------------------------- /docs/sources/terms/images/docker-filesystems-multiroot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fcoury/docker/master/docs/sources/terms/images/docker-filesystems-multiroot.png -------------------------------------------------------------------------------- /docs/sources/terms/images/docker-filesystems-multilayer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fcoury/docker/master/docs/sources/terms/images/docker-filesystems-multilayer.png -------------------------------------------------------------------------------- /docs/theme/docker/static/img/glyphicons-halflings-white.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fcoury/docker/master/docs/theme/docker/static/img/glyphicons-halflings-white.png -------------------------------------------------------------------------------- /hack/allmaintainers.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | find $1 -name MAINTAINERS -exec cat {} ';' | sed -E -e 's/^[^:]*: *(.*)$/\1/' | grep -E -v -e '^ *$' -e '^ *#.*$' | sort -u 4 | -------------------------------------------------------------------------------- /hack/environment/requirements.txt: -------------------------------------------------------------------------------- 1 | sqlalchemy<=0.7.9 2 | sqlalchemy-migrate>=0.7.2 3 | buildbot==0.8.7p1 4 | buildbot_slave==0.8.7p1 5 | nose==1.2.1 6 | requests==1.1.0 7 | -------------------------------------------------------------------------------- /testing/buildbot/requirements.txt: -------------------------------------------------------------------------------- 1 | sqlalchemy<=0.7.9 2 | sqlalchemy-migrate>=0.7.2 3 | buildbot==0.8.7p1 4 | buildbot_slave==0.8.7p1 5 | nose==1.2.1 6 | requests==1.1.0 7 | -------------------------------------------------------------------------------- /docs/sources/examples/example_header.inc: -------------------------------------------------------------------------------- 1 | 2 | .. note:: 3 | 4 | This example assumes you have Docker running in daemon mode. For more information please see :ref:`running_examples` 5 | -------------------------------------------------------------------------------- /contrib/vagrant-docker/README.md: -------------------------------------------------------------------------------- 1 | # Vagrant-docker 2 | 3 | This is a placeholder for the official vagrant-docker, a plugin for Vagrant (http://vagrantup.com) which exposes Docker as a provider. 4 | -------------------------------------------------------------------------------- /packaging/ubuntu/docker.upstart: -------------------------------------------------------------------------------- 1 | description "Run docker" 2 | 3 | start on runlevel [2345] 4 | stop on starting rc RUNLEVEL=[016] 5 | respawn 6 | 7 | script 8 | /usr/bin/docker -d 9 | end script 10 | -------------------------------------------------------------------------------- /mount_darwin.go: -------------------------------------------------------------------------------- 1 | package docker 2 | 3 | import "errors" 4 | 5 | func mount(source string, target string, fstype string, flags uintptr, data string) (err error) { 6 | return errors.New("mount is not implemented on darwin") 7 | } 8 | -------------------------------------------------------------------------------- /mount_linux.go: -------------------------------------------------------------------------------- 1 | package docker 2 | 3 | import "syscall" 4 | 5 | func mount(source string, target string, fstype string, flags uintptr, data string) (err error) { 6 | return syscall.Mount(source, target, fstype, flags, data) 7 | } 8 | -------------------------------------------------------------------------------- /MAINTAINERS: -------------------------------------------------------------------------------- 1 | Solomon Hykes 2 | Guillaume Charmes 3 | Victor Vieux 4 | api.go: Victor Vieux 5 | Vagrantfile: Daniel Mizyrycki 6 | -------------------------------------------------------------------------------- /contrib/README: -------------------------------------------------------------------------------- 1 | The `contrib` directory contains scripts, images, and other helpful things 2 | which are not part of the core docker distribution. Please note that they 3 | could be out of date, since they do not receive the same attention as the 4 | rest of the repository. 5 | -------------------------------------------------------------------------------- /utils/uname_darwin.go: -------------------------------------------------------------------------------- 1 | package utils 2 | 3 | import ( 4 | "errors" 5 | ) 6 | 7 | type Utsname struct { 8 | Release [65]byte 9 | } 10 | 11 | func uname() (*Utsname, error) { 12 | return nil, errors.New("Kernel version detection is not available on darwin") 13 | } 14 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .vagrant* 2 | bin 3 | docker/docker 4 | .*.swp 5 | a.out 6 | *.orig 7 | build_src 8 | command-line-arguments.test 9 | .flymake* 10 | docker.test 11 | auth/auth.test 12 | .idea 13 | .DS_Store 14 | docs/_build 15 | docs/_static 16 | docs/_templates 17 | .gopath/ 18 | -------------------------------------------------------------------------------- /docs/sources/concepts/index.rst: -------------------------------------------------------------------------------- 1 | :title: Concepts 2 | :description: -- todo: change me 3 | :keywords: concepts, documentation, docker, containers 4 | 5 | 6 | 7 | Concepts 8 | ======== 9 | 10 | Contents: 11 | 12 | .. toctree:: 13 | :maxdepth: 1 14 | 15 | ../index 16 | 17 | -------------------------------------------------------------------------------- /docs/sources/commandline/command/version.rst: -------------------------------------------------------------------------------- 1 | :title: Version Command 2 | :description: 3 | :keywords: version, docker, documentation 4 | 5 | ================================================== 6 | ``version`` -- Show the docker version information 7 | ================================================== 8 | -------------------------------------------------------------------------------- /packaging/README.rst: -------------------------------------------------------------------------------- 1 | Docker packaging 2 | ================ 3 | 4 | This directory has one subdirectory per packaging distribution. 5 | At minimum, each of these subdirectories should contain a 6 | README.$DISTRIBUTION explaining how to create the native 7 | docker package and how to install it. 8 | 9 | -------------------------------------------------------------------------------- /docs/theme/docker/theme.conf: -------------------------------------------------------------------------------- 1 | [theme] 2 | inherit = basic 3 | pygments_style = monokai 4 | 5 | [options] 6 | full_logo = true 7 | textcolor = #444444 8 | headingcolor = #0c3762 9 | linkcolor = #8C7B65 10 | visitedlinkcolor = #AFA599 11 | hoverlinkcolor = #4e4334 12 | -------------------------------------------------------------------------------- /docs/website/nginx.conf: -------------------------------------------------------------------------------- 1 | 2 | # rule to redirect original links created when hosted on github pages 3 | rewrite ^/documentation/(.*).html http://docs.docker.io/en/latest/$1/ permanent; 4 | 5 | # rewrite the stuff which was on the current page 6 | rewrite ^/gettingstarted.html$ /gettingstarted/ permanent; 7 | -------------------------------------------------------------------------------- /utils/uname_linux.go: -------------------------------------------------------------------------------- 1 | package utils 2 | 3 | import ( 4 | "syscall" 5 | ) 6 | 7 | type Utsname syscall.Utsname 8 | 9 | func uname() (*syscall.Utsname, error) { 10 | uts := &syscall.Utsname{} 11 | 12 | if err := syscall.Uname(uts); err != nil { 13 | return nil, err 14 | } 15 | return uts, nil 16 | } 17 | -------------------------------------------------------------------------------- /docs/sources/commandline/command/rmi.rst: -------------------------------------------------------------------------------- 1 | :title: Rmi Command 2 | :description: Remove an image 3 | :keywords: rmi, remove, image, docker, documentation 4 | 5 | ========================== 6 | ``rmi`` -- Remove an image 7 | ========================== 8 | 9 | :: 10 | 11 | Usage: docker rmimage [OPTIONS] IMAGE 12 | 13 | Remove an image 14 | -------------------------------------------------------------------------------- /docs/sources/contributing/index.rst: -------------------------------------------------------------------------------- 1 | :title: Contributing to Docker 2 | :description: Guides on how to contribute to docker 3 | :keywords: Docker, documentation, developers, contributing, dev environment 4 | 5 | 6 | 7 | Contributing 8 | ============ 9 | 10 | .. toctree:: 11 | :maxdepth: 1 12 | 13 | contributing 14 | devenvironment 15 | -------------------------------------------------------------------------------- /hack/infrastructure/README.md: -------------------------------------------------------------------------------- 1 | # Docker project infrastructure 2 | 3 | This directory holds all information about the technical infrastructure of the docker project; servers, dns, email, and all the corresponding tools and configuration. 4 | 5 | Obviously credentials should not be stored in this repo, but how to obtain and use them should be documented here. 6 | -------------------------------------------------------------------------------- /docs/sources/commandline/command/rm.rst: -------------------------------------------------------------------------------- 1 | :title: Rm Command 2 | :description: Remove a container 3 | :keywords: remove, container, docker, documentation, rm 4 | 5 | ============================ 6 | ``rm`` -- Remove a container 7 | ============================ 8 | 9 | :: 10 | 11 | Usage: docker rm [OPTIONS] CONTAINER 12 | 13 | Remove a container 14 | -------------------------------------------------------------------------------- /docs/sources/use/index.rst: -------------------------------------------------------------------------------- 1 | :title: Documentation 2 | :description: -- todo: change me 3 | :keywords: todo, docker, documentation, basic, builder 4 | 5 | 6 | 7 | Use 8 | ======== 9 | 10 | Contents: 11 | 12 | .. toctree:: 13 | :maxdepth: 1 14 | 15 | basics 16 | workingwithrepository 17 | port_redirection 18 | builder 19 | puppet 20 | 21 | -------------------------------------------------------------------------------- /docs/sources/terms/index.rst: -------------------------------------------------------------------------------- 1 | :title: Terms 2 | :description: Definitions of terms used in Docker documentation 3 | :keywords: concepts, documentation, docker, containers 4 | 5 | 6 | 7 | Terms 8 | ===== 9 | 10 | Definitions of terms used in Docker documentation. 11 | 12 | Contents: 13 | 14 | .. toctree:: 15 | :maxdepth: 1 16 | 17 | fundamentals 18 | 19 | -------------------------------------------------------------------------------- /docs/sources/commandline/command/stop.rst: -------------------------------------------------------------------------------- 1 | :title: Stop Command 2 | :description: Stop a running container 3 | :keywords: stop, container, docker, documentation 4 | 5 | ==================================== 6 | ``stop`` -- Stop a running container 7 | ==================================== 8 | 9 | :: 10 | 11 | Usage: docker stop [OPTIONS] NAME 12 | 13 | Stop a running container 14 | -------------------------------------------------------------------------------- /docs/sources/api/index.rst: -------------------------------------------------------------------------------- 1 | :title: API Documentation 2 | :description: docker documentation 3 | :keywords: docker, ipa, documentation 4 | 5 | APIs 6 | ==== 7 | 8 | Your programs and scripts can access Docker's functionality via these interfaces: 9 | 10 | .. toctree:: 11 | :maxdepth: 3 12 | 13 | registry_index_spec 14 | registry_api 15 | index_api 16 | docker_remote_api 17 | 18 | 19 | -------------------------------------------------------------------------------- /docs/sources/commandline/command/start.rst: -------------------------------------------------------------------------------- 1 | :title: Start Command 2 | :description: Start a stopped container 3 | :keywords: start, docker, container, documentation 4 | 5 | ====================================== 6 | ``start`` -- Start a stopped container 7 | ====================================== 8 | 9 | :: 10 | 11 | Usage: docker start [OPTIONS] NAME 12 | 13 | Start a stopped container 14 | -------------------------------------------------------------------------------- /docs/theme/docker/redirect_home.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Page Moved 5 | 6 | 7 | 8 | 9 | This page has moved. Perhaps you should visit the Documentation Homepage 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /docs/sources/commandline/command/kill.rst: -------------------------------------------------------------------------------- 1 | :title: Kill Command 2 | :description: Kill a running container 3 | :keywords: kill, container, docker, documentation 4 | 5 | ==================================== 6 | ``kill`` -- Kill a running container 7 | ==================================== 8 | 9 | :: 10 | 11 | Usage: docker kill [OPTIONS] CONTAINER [CONTAINER...] 12 | 13 | Kill a running container 14 | -------------------------------------------------------------------------------- /docs/sources/commandline/command/info.rst: -------------------------------------------------------------------------------- 1 | :title: Info Command 2 | :description: Display system-wide information. 3 | :keywords: info, docker, information, documentation 4 | 5 | =========================================== 6 | ``info`` -- Display system-wide information 7 | =========================================== 8 | 9 | :: 10 | 11 | Usage: docker info 12 | 13 | Display system-wide information. 14 | -------------------------------------------------------------------------------- /docs/sources/commandline/command/logs.rst: -------------------------------------------------------------------------------- 1 | :title: Logs Command 2 | :description: Fetch the logs of a container 3 | :keywords: logs, container, docker, documentation 4 | 5 | ========================================= 6 | ``logs`` -- Fetch the logs of a container 7 | ========================================= 8 | 9 | :: 10 | 11 | Usage: docker logs [OPTIONS] CONTAINER 12 | 13 | Fetch the logs of a container 14 | -------------------------------------------------------------------------------- /docs/sources/api/README.md: -------------------------------------------------------------------------------- 1 | This directory holds the authoritative specifications of APIs defined and implemented by Docker. Currently this includes: 2 | 3 | * The remote API by which a docker node can be queried over HTTP 4 | * The registry API by which a docker node can download and upload container images for storage and sharing 5 | * The index search API by which a docker node can search the public index for images to download 6 | -------------------------------------------------------------------------------- /docs/sources/commandline/command/attach.rst: -------------------------------------------------------------------------------- 1 | :title: Attach Command 2 | :description: Attach to a running container 3 | :keywords: attach, container, docker, documentation 4 | 5 | =========================================== 6 | ``attach`` -- Attach to a running container 7 | =========================================== 8 | 9 | :: 10 | 11 | Usage: docker attach CONTAINER 12 | 13 | Attach to a running container 14 | -------------------------------------------------------------------------------- /docs/sources/commandline/command/restart.rst: -------------------------------------------------------------------------------- 1 | :title: Restart Command 2 | :description: Restart a running container 3 | :keywords: restart, container, docker, documentation 4 | 5 | ========================================== 6 | ``restart`` -- Restart a running container 7 | ========================================== 8 | 9 | :: 10 | 11 | Usage: docker restart [OPTIONS] NAME 12 | 13 | Restart a running container 14 | -------------------------------------------------------------------------------- /docs/sources/commandline/command/history.rst: -------------------------------------------------------------------------------- 1 | :title: History Command 2 | :description: Show the history of an image 3 | :keywords: history, docker, container, documentation 4 | 5 | =========================================== 6 | ``history`` -- Show the history of an image 7 | =========================================== 8 | 9 | :: 10 | 11 | Usage: docker history [OPTIONS] IMAGE 12 | 13 | Show the history of an image 14 | -------------------------------------------------------------------------------- /docs/sources/installation/index.rst: -------------------------------------------------------------------------------- 1 | :title: Documentation 2 | :description: -- todo: change me 3 | :keywords: todo, docker, documentation, installation, OS support 4 | 5 | 6 | 7 | Installation 8 | ============ 9 | 10 | Contents: 11 | 12 | .. toctree:: 13 | :maxdepth: 1 14 | 15 | ubuntulinux 16 | binaries 17 | vagrant 18 | windows 19 | amazon 20 | rackspace 21 | archlinux 22 | upgrading 23 | kernel 24 | -------------------------------------------------------------------------------- /docs/sources/contributing/contributing.rst: -------------------------------------------------------------------------------- 1 | :title: Contribution Guidelines 2 | :description: Contribution guidelines: create issues, convetions, pull requests 3 | :keywords: contributing, docker, documentation, help, guideline 4 | 5 | Contributing to Docker 6 | ====================== 7 | 8 | Want to hack on Docker? Awesome! The repository includes `all the instructions you need to get started `_. 9 | 10 | -------------------------------------------------------------------------------- /docs/sources/static_files/README.md: -------------------------------------------------------------------------------- 1 | Static files dir 2 | ================ 3 | 4 | Files you put in /sources/static_files/ will be copied to the web visible /_static/ 5 | 6 | Be careful not to override pre-existing static files from the template. 7 | 8 | Generally, layout related files should go in the /theme directory. 9 | 10 | If you want to add images to your particular documentation page. Just put them next to 11 | your .rst source file and reference them relatively. -------------------------------------------------------------------------------- /docs/sources/commandline/command/tag.rst: -------------------------------------------------------------------------------- 1 | :title: Tag Command 2 | :description: Tag an image into a repository 3 | :keywords: tag, docker, image, repository, documentation, repo 4 | 5 | ========================================= 6 | ``tag`` -- Tag an image into a repository 7 | ========================================= 8 | 9 | :: 10 | 11 | Usage: docker tag [OPTIONS] IMAGE REPOSITORY [TAG] 12 | 13 | Tag an image into a repository 14 | 15 | -f=false: Force 16 | -------------------------------------------------------------------------------- /docs/sources/commandline/command/login.rst: -------------------------------------------------------------------------------- 1 | :title: Login Command 2 | :description: Register or Login to the docker registry server 3 | :keywords: login, docker, documentation 4 | 5 | ============================================================ 6 | ``login`` -- Register or Login to the docker registry server 7 | ============================================================ 8 | 9 | :: 10 | 11 | Usage: docker login 12 | 13 | Register or Login to the docker registry server 14 | -------------------------------------------------------------------------------- /docs/sources/commandline/command/diff.rst: -------------------------------------------------------------------------------- 1 | :title: Diff Command 2 | :description: Inspect changes on a container's filesystem 3 | :keywords: diff, docker, container, documentation 4 | 5 | ======================================================= 6 | ``diff`` -- Inspect changes on a container's filesystem 7 | ======================================================= 8 | 9 | :: 10 | 11 | Usage: docker diff CONTAINER [OPTIONS] 12 | 13 | Inspect changes on a container's filesystem 14 | -------------------------------------------------------------------------------- /docs/sources/commandline/command/inspect.rst: -------------------------------------------------------------------------------- 1 | :title: Inspect Command 2 | :description: Return low-level information on a container 3 | :keywords: inspect, container, docker, documentation 4 | 5 | ========================================================== 6 | ``inspect`` -- Return low-level information on a container 7 | ========================================================== 8 | 9 | :: 10 | 11 | Usage: docker inspect [OPTIONS] CONTAINER 12 | 13 | Return low-level information on a container 14 | -------------------------------------------------------------------------------- /docs/sources/commandline/command/ps.rst: -------------------------------------------------------------------------------- 1 | :title: Ps Command 2 | :description: List containers 3 | :keywords: ps, docker, documentation, container 4 | 5 | ========================= 6 | ``ps`` -- List containers 7 | ========================= 8 | 9 | :: 10 | 11 | Usage: docker ps [OPTIONS] 12 | 13 | List containers 14 | 15 | -a=false: Show all containers. Only running containers are shown by default. 16 | -notrunc=false: Don't truncate output 17 | -q=false: Only display numeric IDs 18 | -------------------------------------------------------------------------------- /packaging/ubuntu/rules: -------------------------------------------------------------------------------- 1 | #!/usr/bin/make -f 2 | # -*- makefile -*- 3 | # Sample debian/rules that uses debhelper. 4 | # This file was originally written by Joey Hess and Craig Small. 5 | # As a special exception, when this file is copied by dh-make into a 6 | # dh-make output file, you may use that output file without restriction. 7 | # This special exception was added by Craig Small in version 0.37 of dh-make. 8 | 9 | # Uncomment this to turn on verbose mode. 10 | #export DH_VERBOSE=1 11 | 12 | %: 13 | dh $@ 14 | -------------------------------------------------------------------------------- /docs/sources/examples/index.rst: -------------------------------------------------------------------------------- 1 | :title: Docker Examples 2 | :description: Examples on how to use Docker 3 | :keywords: docker, hello world, node, nodejs, python, couch, couchdb, redis, ssh, sshd, examples 4 | 5 | 6 | 7 | Examples 8 | ============ 9 | 10 | Contents: 11 | 12 | .. toctree:: 13 | :maxdepth: 1 14 | 15 | running_examples 16 | hello_world 17 | hello_world_daemon 18 | python_web_app 19 | nodejs_web_app 20 | running_redis_service 21 | running_ssh_service 22 | couchdb_data_volumes 23 | -------------------------------------------------------------------------------- /docs/sources/commandline/command/export.rst: -------------------------------------------------------------------------------- 1 | :title: Export Command 2 | :description: Export the contents of a filesystem as a tar archive 3 | :keywords: export, docker, container, documentation 4 | 5 | ================================================================= 6 | ``export`` -- Stream the contents of a container as a tar archive 7 | ================================================================= 8 | 9 | :: 10 | 11 | Usage: docker export CONTAINER 12 | 13 | Export the contents of a filesystem as a tar archive 14 | -------------------------------------------------------------------------------- /docs/sources/commandline/command/push.rst: -------------------------------------------------------------------------------- 1 | :title: Push Command 2 | :description: Push an image or a repository to the registry 3 | :keywords: push, docker, image, repository, documentation, repo 4 | 5 | ======================================================================= 6 | ``push`` -- Push an image or a repository to the docker registry server 7 | ======================================================================= 8 | 9 | :: 10 | 11 | Usage: docker push NAME 12 | 13 | Push an image or a repository to the registry 14 | -------------------------------------------------------------------------------- /docs/sources/commandline/command/pull.rst: -------------------------------------------------------------------------------- 1 | :title: Pull Command 2 | :description: Pull an image or a repository from the registry 3 | :keywords: pull, image, repo, repository, documentation, docker 4 | 5 | ========================================================================= 6 | ``pull`` -- Pull an image or a repository from the docker registry server 7 | ========================================================================= 8 | 9 | :: 10 | 11 | Usage: docker pull NAME 12 | 13 | Pull an image or a repository from the registry 14 | -------------------------------------------------------------------------------- /docs/sources/commandline/command/wait.rst: -------------------------------------------------------------------------------- 1 | :title: Wait Command 2 | :description: Block until a container stops, then print its exit code. 3 | :keywords: wait, docker, container, documentation 4 | 5 | =================================================================== 6 | ``wait`` -- Block until a container stops, then print its exit code 7 | =================================================================== 8 | 9 | :: 10 | 11 | Usage: docker wait [OPTIONS] NAME 12 | 13 | Block until a container stops, then print its exit code. 14 | -------------------------------------------------------------------------------- /hack/environment/bash_profile: -------------------------------------------------------------------------------- 1 | # ~/.bash_profile : executed by the command interpreter for login shells. 2 | 3 | # if running bash 4 | if [ -n "$BASH_VERSION" ]; then 5 | # include .bashrc if it exists 6 | if [ -f "$HOME/.bashrc" ]; then 7 | . "$HOME/.bashrc" 8 | fi 9 | fi 10 | 11 | # set PATH so it includes user's private bin if it exists 12 | [ -d "$HOME/bin" ] && PATH="$HOME/bin:$PATH" 13 | 14 | docker=/data/docker/src/github.com/dotcloud/docker 15 | [ -d $docker ] && cd $docker 16 | 17 | export GOPATH=/data/docker 18 | export PATH=$PATH:$GOPATH/bin 19 | 20 | -------------------------------------------------------------------------------- /docs/sources/commandline/command/port.rst: -------------------------------------------------------------------------------- 1 | :title: Port Command 2 | :description: Lookup the public-facing port which is NAT-ed to PRIVATE_PORT 3 | :keywords: port, docker, container, documentation 4 | 5 | ========================================================================= 6 | ``port`` -- Lookup the public-facing port which is NAT-ed to PRIVATE_PORT 7 | ========================================================================= 8 | 9 | :: 10 | 11 | Usage: docker port [OPTIONS] CONTAINER PRIVATE_PORT 12 | 13 | Lookup the public-facing port which is NAT-ed to PRIVATE_PORT 14 | -------------------------------------------------------------------------------- /docs/sources/toctree.rst: -------------------------------------------------------------------------------- 1 | :title: Documentation 2 | :description: -- todo: change me 3 | :keywords: todo, docker, documentation, installation, usage, examples, contributing, faq, command line, concepts 4 | 5 | Documentation 6 | ============= 7 | 8 | This documentation has the following resources: 9 | 10 | .. toctree:: 11 | :titlesonly: 12 | 13 | concepts/index 14 | installation/index 15 | use/index 16 | examples/index 17 | commandline/index 18 | contributing/index 19 | api/index 20 | faq 21 | terms/index 22 | 23 | .. image:: concepts/images/lego_docker.jpg 24 | -------------------------------------------------------------------------------- /hack/environment/buildbot.conf: -------------------------------------------------------------------------------- 1 | [program:buildmaster] 2 | command=su vagrant -c "buildbot start master" 3 | directory=/data/buildbot 4 | chown= root:root 5 | redirect_stderr=true 6 | stdout_logfile=/var/log/supervisor/buildbot-master.log 7 | stderr_logfile=/var/log/supervisor/buildbot-master.log 8 | 9 | [program:buildworker] 10 | command=buildslave start slave 11 | directory=/data/buildbot 12 | chown= root:root 13 | redirect_stderr=true 14 | stdout_logfile=/var/log/supervisor/buildbot-slave.log 15 | stderr_logfile=/var/log/supervisor/buildbot-slave.log 16 | 17 | [group:buildbot] 18 | programs=buildmaster,buildworker 19 | -------------------------------------------------------------------------------- /docs/sources/commandline/command/search.rst: -------------------------------------------------------------------------------- 1 | :title: Search Command 2 | :description: Searches for the TERM parameter on the Docker index and prints out a list of repositories that match. 3 | :keywords: search, docker, image, documentation 4 | 5 | =================================================================== 6 | ``search`` -- Search for an image in the docker index 7 | =================================================================== 8 | 9 | :: 10 | 11 | Usage: docker search TERM 12 | 13 | Searches for the TERM parameter on the Docker index and prints out a list of repositories 14 | that match. 15 | -------------------------------------------------------------------------------- /NOTICE: -------------------------------------------------------------------------------- 1 | Docker 2 | Copyright 2012-2013 dotCloud, inc. 3 | 4 | This product includes software developed at dotCloud, inc. (http://www.dotcloud.com). 5 | 6 | This product contains software (https://github.com/kr/pty) developed by Keith Rarick, licensed under the MIT License. 7 | 8 | Transfers of Docker shall be in accordance with applicable export controls of any country and all other applicable 9 | legal requirements. Docker shall not be distributed or downloaded to or in Cuba, Iran, North Korea, Sudan or Syria 10 | and shall not be distributed or downloaded to any person on the Denied Persons List administered by the U.S. 11 | Department of Commerce. 12 | -------------------------------------------------------------------------------- /testing/buildbot/buildbot.conf: -------------------------------------------------------------------------------- 1 | [program:buildmaster] 2 | command=twistd --nodaemon --no_save -y buildbot.tac 3 | directory=/data/buildbot/master 4 | chown= root:root 5 | redirect_stderr=true 6 | stdout_logfile=/var/log/supervisor/buildbot-master.log 7 | stderr_logfile=/var/log/supervisor/buildbot-master.log 8 | 9 | [program:buildworker] 10 | command=twistd --nodaemon --no_save -y buildbot.tac 11 | directory=/data/buildbot/slave 12 | chown= root:root 13 | redirect_stderr=true 14 | stdout_logfile=/var/log/supervisor/buildbot-slave.log 15 | stderr_logfile=/var/log/supervisor/buildbot-slave.log 16 | 17 | [group:buildbot] 18 | programs=buildmaster,buildworker 19 | -------------------------------------------------------------------------------- /docs/sources/commandline/command/images.rst: -------------------------------------------------------------------------------- 1 | :title: Images Command 2 | :description: List images 3 | :keywords: images, docker, container, documentation 4 | 5 | ========================= 6 | ``images`` -- List images 7 | ========================= 8 | 9 | :: 10 | 11 | Usage: docker images [OPTIONS] [NAME] 12 | 13 | List images 14 | 15 | -a=false: show all images 16 | -q=false: only show numeric IDs 17 | -viz=false: output in graphviz format 18 | 19 | Displaying images visually 20 | -------------------------- 21 | 22 | :: 23 | 24 | docker images -viz | dot -Tpng -o docker.png 25 | 26 | .. image:: images/docker_images.gif 27 | -------------------------------------------------------------------------------- /hack/environment/post-commit: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | '''Trigger buildbot docker test build 4 | 5 | post-commit git hook designed to automatically trigger buildbot on 6 | the provided vagrant docker VM.''' 7 | 8 | import requests 9 | 10 | USERNAME = 'buildbot' 11 | PASSWORD = 'docker' 12 | BASE_URL = 'http://localhost:8010' 13 | path = lambda s: BASE_URL + '/' + s 14 | 15 | try: 16 | session = requests.session() 17 | session.post(path('login'),data={'username':USERNAME,'passwd':PASSWORD}) 18 | session.post(path('builders/docker/force'), 19 | data={'forcescheduler':'trigger','reason':'Test commit'}) 20 | except: 21 | pass 22 | -------------------------------------------------------------------------------- /docs/sources/examples/running_examples.rst: -------------------------------------------------------------------------------- 1 | :title: Running the Examples 2 | :description: An overview on how to run the docker examples 3 | :keywords: docker, examples, how to 4 | 5 | .. _running_examples: 6 | 7 | Running the Examples 8 | -------------------- 9 | 10 | All the examples assume your machine is running the docker daemon. To run the docker daemon in the background, simply type: 11 | 12 | .. code-block:: bash 13 | 14 | sudo docker -d & 15 | 16 | Now you can run docker in client mode: all commands will be forwarded to the docker daemon, so the client 17 | can run from any account. 18 | 19 | .. code-block:: bash 20 | 21 | # now you can run docker commands from any account. 22 | docker help 23 | -------------------------------------------------------------------------------- /packaging/archlinux/README.archlinux: -------------------------------------------------------------------------------- 1 | Docker on Arch 2 | ============== 3 | 4 | The AUR lxc-docker and lxc-docker-git packages handle building docker on Arch 5 | linux. The PKGBUILD specifies all dependencies, build, and packaging steps. 6 | 7 | Dependencies 8 | ============ 9 | 10 | The only buildtime dependencies are git and go which are available via pacman. 11 | The -s flag can be used on makepkg commands below to automatically install 12 | these dependencies. 13 | 14 | Building Package 15 | ================ 16 | 17 | Download the tarball for either AUR packaged to a local directory. In that 18 | directory makepkg can be run to build the package. 19 | 20 | # Build the binary package 21 | makepkg 22 | 23 | # Build an updated source tarball 24 | makepkg --source 25 | 26 | -------------------------------------------------------------------------------- /packaging/debian/maintainer.rst: -------------------------------------------------------------------------------- 1 | Maintainer duty 2 | =============== 3 | 4 | The Debian project specifies the role of a 'maintainer' which is the person 5 | making the Debian package of the program. This role requires an 'sponsor' to 6 | upload the package. As a maintainer you should follow the guide 7 | http://www.debian.org/doc/manuals/maint-guide . Your sponsor will be there 8 | helping you succeed. 9 | 10 | The most relevant information to update is the changelog file: 11 | Each new release should create a new first paragraph with new release version, 12 | changes, and the maintainer information. 13 | 14 | After this is done, follow README.debian to generate the actual source 15 | packages and talk with your sponsor to upload them into the official Debian 16 | package archive. 17 | -------------------------------------------------------------------------------- /packaging/ubuntu/control: -------------------------------------------------------------------------------- 1 | Source: lxc-docker 2 | Section: misc 3 | Priority: extra 4 | Maintainer: Daniel Mizyrycki 5 | Build-Depends: debhelper,autotools-dev,devscripts,golang-stable 6 | Standards-Version: 3.9.3 7 | Homepage: http://github.com/dotcloud/docker 8 | 9 | Package: lxc-docker 10 | Architecture: linux-any 11 | Depends: ${misc:Depends},${shlibs:Depends},lxc,bsdtar,aufs-tools 12 | Conflicts: docker 13 | Description: lxc-docker is a Linux container runtime 14 | Docker complements LXC with a high-level API which operates at the process 15 | level. It runs unix processes with strong guarantees of isolation and 16 | repeatability across servers. 17 | Docker is a great building block for automating distributed systems: 18 | large-scale web deployments, database clusters, continuous deployment systems, 19 | private PaaS, service-oriented architectures, etc. 20 | -------------------------------------------------------------------------------- /packaging/ubuntu/parse_changelog.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | 'Parse main CHANGELOG.md from stdin outputing on stdout the ubuntu changelog' 4 | 5 | import sys,re, datetime 6 | 7 | on_block=False 8 | for line in sys.stdin.readlines(): 9 | line = line.strip() 10 | if line.startswith('# ') or len(line) == 0: 11 | continue 12 | if line.startswith('## '): 13 | if on_block: 14 | print '\n -- dotCloud {0}\n'.format(date) 15 | version, date = line[3:].split() 16 | date = datetime.datetime.strptime(date, '(%Y-%m-%d)').strftime( 17 | '%a, %d %b %Y 00:00:00 -0700') 18 | on_block = True 19 | print 'lxc-docker ({0}-1) precise; urgency=low'.format(version) 20 | continue 21 | if on_block: 22 | print ' ' + line 23 | print '\n -- dotCloud {0}'.format(date) 24 | -------------------------------------------------------------------------------- /packaging/debian/README.Debian: -------------------------------------------------------------------------------- 1 | Docker on Debian 2 | ================ 3 | 4 | Docker has been built and tested on Wheezy. All docker functionality works 5 | out of the box, except for memory limitation as the stock debian kernel 6 | disables it by default. To enable docker memory limitation, the kernel needs 7 | to be loaded with boot parameters: cgroup_enable=memory swapaccount=1 8 | 9 | 10 | Building docker package 11 | ~~~~~~~~~~~~~~~~~~~~~~~ 12 | 13 | Assuming you have a wheezy system up and running 14 | 15 | # Get building dependencies 16 | sudo apt-get update 17 | sudo apt-get install -y debhelper build-essential autotools-dev golang 18 | 19 | # Make the debian package 20 | git clone https://github.com/dotcloud/docker.git 21 | cd docker/packaging/debian 22 | make debian 23 | 24 | 25 | Install docker package 26 | ~~~~~~~~~~~~~~~~~~~~~~ 27 | 28 | sudo dpkg -i lxc-docker_*-1_amd64.deb; sudo apt-get install -f -y 29 | -------------------------------------------------------------------------------- /packaging/ubuntu/Vagrantfile: -------------------------------------------------------------------------------- 1 | GOPHERS_KEY = "308C15A29AD198E9" 2 | 3 | Vagrant::Config.run do |config| 4 | config.vm.box = 'precise64' 5 | config.vm.box_url = 'http://files.vagrantup.com/precise64.box' 6 | config.vm.share_folder 'v-data', '/data/docker', "#{File.dirname(__FILE__)}/../.." 7 | 8 | # Add docker PPA key to the local repository and install docker 9 | pkg_cmd = "apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys #{GOPHERS_KEY}; " \ 10 | "echo 'deb http://ppa.launchpad.net/gophers/go/ubuntu precise main' >/etc/apt/sources.list.d/gophers-go.list; " \ 11 | # Install ubuntu packaging dependencies and create ubuntu packages 12 | pkg_cmd << "export DEBIAN_FRONTEND=noninteractive; apt-get -qq update; apt-get install -qq -y git debhelper autotools-dev devscripts golang-stable; " \ 13 | "export GPG_KEY='#{ENV['GPG_KEY']}'; cd /data/docker/packaging/ubuntu; make ubuntu" 14 | config.vm.provision :shell, :inline => pkg_cmd 15 | end 16 | -------------------------------------------------------------------------------- /docs/sources/use/port_redirection.rst: -------------------------------------------------------------------------------- 1 | :title: Port redirection 2 | :description: usage about port redirection 3 | :keywords: Usage, basic port, docker, documentation, examples 4 | 5 | 6 | Port redirection 7 | ================ 8 | 9 | Docker can redirect public tcp ports to your container, so it can be reached over the network. 10 | Port redirection is done on ``docker run`` using the -p flag. 11 | 12 | A port redirect is specified as PUBLIC:PRIVATE, where tcp port PUBLIC will be redirected to 13 | tcp port PRIVATE. As a special case, the public port can be omitted, in which case a random 14 | public port will be allocated. 15 | 16 | .. code-block:: bash 17 | 18 | # A random PUBLIC port is redirected to PRIVATE port 80 on the container 19 | docker run -p 80 20 | 21 | # PUBLIC port 80 is redirected to PRIVATE port 80 22 | docker run -p 80:80 23 | 24 | 25 | Default port redirects can be built into a container with the EXPOSE build command. 26 | -------------------------------------------------------------------------------- /packaging/debian/control: -------------------------------------------------------------------------------- 1 | Source: lxc-docker 2 | Section: admin 3 | Priority: optional 4 | Maintainer: Daniel Mizyrycki 5 | Build-Depends: debhelper (>=9), autotools-dev, golang 6 | Standards-Version: 3.9.4 7 | Vcs-Git: git://git.debian.org/git/collab-maint/lxc-docker.git 8 | Vcs-Browser: http://anonscm.debian.org/gitweb/?p=collab-maint/lxc-docker.git;a=summary 9 | Homepage: http://github.com/dotcloud/docker 10 | 11 | Package: lxc-docker 12 | Architecture: linux-any 13 | Depends: ${shlibs:Depends}, ${misc:Depends}, lxc, bsdtar, aufs-tools 14 | Description: Linux container runtime 15 | Docker complements LXC with a high-level API which operates at the process 16 | level. It runs unix processes with strong guarantees of isolation and 17 | repeatability across servers. 18 | Docker is a great building block for automating distributed systems: 19 | large-scale web deployments, database clusters, continuous deployment systems, 20 | private PaaS, service-oriented architectures, etc. 21 | -------------------------------------------------------------------------------- /packaging/debian/Vagrantfile: -------------------------------------------------------------------------------- 1 | VM_IP = "192.168.33.31" 2 | PKG_DEP = "git debhelper build-essential autotools-dev devscripts golang" 3 | 4 | Vagrant::Config.run do |config| 5 | config.vm.box = 'debian-7.0.rc1.64' 6 | config.vm.box_url = 'http://puppet-vagrant-boxes.puppetlabs.com/debian-70rc1-x64-vbox4210-nocm.box' 7 | config.vm.share_folder 'v-data', '/data/docker', "#{File.dirname(__FILE__)}/../.." 8 | config.vm.network :hostonly,VM_IP 9 | 10 | # Add kernel cgroup memory limitation boot parameters 11 | grub_cmd="sed -i 's#DEFAULT=\"quiet\"#DEFAULT=\"cgroup_enable=memory swapaccount=1 quiet\"#' /etc/default/grub" 12 | config.vm.provision :shell, :inline => "#{grub_cmd};update-grub" 13 | 14 | # Install debian packaging dependencies and create debian packages 15 | pkg_cmd = "apt-get -qq update; DEBIAN_FRONTEND=noninteractive apt-get install -qq -y #{PKG_DEP}; " \ 16 | "export GPG_KEY='#{ENV['GPG_KEY']}'; cd /data/docker/packaging/debian; make debian" 17 | config.vm.provision :shell, :inline => pkg_cmd 18 | end 19 | -------------------------------------------------------------------------------- /packaging/debian/copyright: -------------------------------------------------------------------------------- 1 | Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ 2 | Upstream-Name: docker 3 | Upstream-Contact: dotCloud Inc 4 | Source: http://github.com/dotcloud/docker 5 | 6 | Files: * 7 | Copyright: 2012, dotCloud Inc 8 | License: Apache-2.0 9 | Licensed under the Apache License, Version 2.0 (the "License"); 10 | you may not use this file except in compliance with the License. 11 | You may obtain a copy of the License at 12 | . 13 | http://www.apache.org/licenses/LICENSE-2.0 14 | . 15 | Unless required by applicable law or agreed to in writing, software 16 | distributed under the License is distributed on an "AS IS" BASIS, 17 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | See the License for the specific language governing permissions and 19 | limitations under the License. 20 | . 21 | On Debian systems, the complete text of the Apache version 2.0 license 22 | can be found in "/usr/share/common-licenses/Apache-2.0". 23 | -------------------------------------------------------------------------------- /docs/sources/commandline/index.rst: -------------------------------------------------------------------------------- 1 | :title: Commands 2 | :description: -- todo: change me 3 | :keywords: todo, commands, command line, help, docker, documentation 4 | 5 | 6 | Commands 7 | ======== 8 | 9 | Contents: 10 | 11 | .. toctree:: 12 | :maxdepth: 1 13 | 14 | cli 15 | attach 16 | build 17 | commit 18 | diff 19 | export 20 | history 21 | images 22 | import 23 | info 24 | inspect 25 | kill 26 | login 27 | logs 28 | port 29 | ps 30 | pull 31 | push 32 | restart 33 | rm 34 | rmi 35 | run 36 | search 37 | start 38 | stop 39 | tag 40 | version 41 | wait -------------------------------------------------------------------------------- /state.go: -------------------------------------------------------------------------------- 1 | package docker 2 | 3 | import ( 4 | "fmt" 5 | "github.com/dotcloud/docker/utils" 6 | "sync" 7 | "time" 8 | ) 9 | 10 | type State struct { 11 | Running bool 12 | Pid int 13 | ExitCode int 14 | StartedAt time.Time 15 | l *sync.Mutex 16 | Ghost bool 17 | } 18 | 19 | // String returns a human-readable description of the state 20 | func (s *State) String() string { 21 | if s.Running { 22 | if s.Ghost { 23 | return fmt.Sprintf("Ghost") 24 | } 25 | return fmt.Sprintf("Up %s", utils.HumanDuration(time.Now().Sub(s.StartedAt))) 26 | } 27 | return fmt.Sprintf("Exit %d", s.ExitCode) 28 | } 29 | 30 | func (s *State) setRunning(pid int) { 31 | s.Running = true 32 | s.ExitCode = 0 33 | s.Pid = pid 34 | s.StartedAt = time.Now() 35 | } 36 | 37 | func (s *State) setStopped(exitCode int) { 38 | s.Running = false 39 | s.Pid = 0 40 | s.ExitCode = exitCode 41 | } 42 | 43 | func (s *State) initLock() { 44 | s.l = &sync.Mutex{} 45 | } 46 | 47 | func (s *State) lock() { 48 | s.l.Lock() 49 | } 50 | 51 | func (s *State) unlock() { 52 | s.l.Unlock() 53 | } 54 | -------------------------------------------------------------------------------- /hack/dockerbuilder/dockerbuilder: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -x 3 | set -e 4 | 5 | export PATH=/usr/local/go/bin:$PATH 6 | 7 | PACKAGE=github.com/dotcloud/docker 8 | 9 | if [ $# -gt 1 ]; then 10 | echo "Usage: $0 [REVISION]" 11 | exit 1 12 | fi 13 | 14 | export REVISION=$1 15 | 16 | if [ -z "$AWS_ID" -o -z "$AWS_KEY" ]; then 17 | echo "Warning: either AWS_ID or AWS_KEY environment variable not set. Won't upload to S3." 18 | else 19 | /bin/echo -e "[default]\naccess_key = $AWS_ID\nsecret_key = $AWS_KEY\n" > /.s3cfg 20 | fi 21 | 22 | if [ -z "$GPG_KEY" ]; then 23 | echo "Warning: environment variable GPG_KEY is not set. Ubuntu package upload will not succeed." 24 | NO_UBUNTU=1 25 | fi 26 | 27 | rm -fr docker-release 28 | git clone https://github.com/dotcloud/docker docker-release 29 | cd docker-release 30 | if [ -z "$REVISION" ]; then 31 | make release 32 | else 33 | make release RELEASE_VERSION=$REVISION 34 | fi 35 | 36 | # Remove credentials from container 37 | rm -f /.s3cfg 38 | 39 | if [ -z "$NO_UBUNTU" ]; then 40 | export PATH=`echo $PATH | sed 's#/usr/local/go/bin:##g'` 41 | (cd packaging/ubuntu && make ubuntu) 42 | fi 43 | -------------------------------------------------------------------------------- /docs/sources/commandline/command/run.rst: -------------------------------------------------------------------------------- 1 | :title: Run Command 2 | :description: Run a command in a new container 3 | :keywords: run, container, docker, documentation 4 | 5 | =========================================== 6 | ``run`` -- Run a command in a new container 7 | =========================================== 8 | 9 | :: 10 | 11 | Usage: docker run [OPTIONS] IMAGE [COMMAND] [ARG...] 12 | 13 | Run a command in a new container 14 | 15 | -a=map[]: Attach to stdin, stdout or stderr. 16 | -c=0: CPU shares (relative weight) 17 | -d=false: Detached mode: leave the container running in the background 18 | -e=[]: Set environment variables 19 | -h="": Container host name 20 | -i=false: Keep stdin open even if not attached 21 | -m=0: Memory limit (in bytes) 22 | -p=[]: Map a network port to the container 23 | -t=false: Allocate a pseudo-tty 24 | -u="": Username or UID 25 | -d=[]: Set custom dns servers for the container 26 | -v=[]: Creates a new volume and mounts it at the specified path. 27 | -volumes-from="": Mount all volumes from the given container. 28 | -------------------------------------------------------------------------------- /hack/README.rst: -------------------------------------------------------------------------------- 1 | This directory contains material helpful for hacking on docker. 2 | 3 | make hack 4 | ========= 5 | 6 | Set up an Ubuntu 13.04 virtual machine for developers including kernel 3.8 7 | and buildbot. The environment is setup in a way that can be used through 8 | the usual go workflow and/or the root Makefile. You can either edit on 9 | your host, or inside the VM (using make ssh-dev) and run and test docker 10 | inside the VM. 11 | 12 | dependencies: vagrant, virtualbox packages and python package requests 13 | 14 | 15 | Buildbot 16 | ~~~~~~~~ 17 | 18 | Buildbot is a continuous integration system designed to automate the 19 | build/test cycle. By automatically rebuilding and testing the tree each time 20 | something has changed, build problems are pinpointed quickly, before other 21 | developers are inconvenienced by the failure. 22 | 23 | When running 'make hack' at the docker root directory, it spawns a virtual 24 | machine in the background running a buildbot instance and adds a git 25 | post-commit hook that automatically run docker tests for you. 26 | 27 | You can check your buildbot instance at http://192.168.33.21:8010/waterfall 28 | -------------------------------------------------------------------------------- /contrib/mkimage-busybox.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Generate a very minimal filesystem based on busybox-static, 3 | # and load it into the local docker under the name "busybox". 4 | 5 | BUSYBOX=$(which busybox) 6 | [ "$BUSYBOX" ] || { 7 | echo "Sorry, I could not locate busybox." 8 | echo "Try 'apt-get install busybox-static'?" 9 | exit 1 10 | } 11 | 12 | set -e 13 | ROOTFS=/tmp/rootfs-busybox-$$-$RANDOM 14 | mkdir $ROOTFS 15 | cd $ROOTFS 16 | 17 | mkdir bin etc dev dev/pts lib proc sys tmp 18 | touch etc/resolv.conf 19 | cp /etc/nsswitch.conf etc/nsswitch.conf 20 | echo root:x:0:0:root:/:/bin/sh > etc/passwd 21 | echo root:x:0: > etc/group 22 | ln -s lib lib64 23 | ln -s bin sbin 24 | cp $BUSYBOX bin 25 | for X in $(busybox --list) 26 | do 27 | ln -s busybox bin/$X 28 | done 29 | rm bin/init 30 | ln bin/busybox bin/init 31 | cp /lib/x86_64-linux-gnu/lib{pthread,c,dl,nsl,nss_*}.so.* lib 32 | cp /lib/x86_64-linux-gnu/ld-linux-x86-64.so.2 lib 33 | for X in console null ptmx random stdin stdout stderr tty urandom zero 34 | do 35 | cp -a /dev/$X dev 36 | done 37 | 38 | tar -cf- . | docker import - busybox 39 | docker run -i -u root busybox /bin/echo Success. 40 | -------------------------------------------------------------------------------- /docs/sources/commandline/command/commit.rst: -------------------------------------------------------------------------------- 1 | :title: Commit Command 2 | :description: Create a new image from a container's changes 3 | :keywords: commit, docker, container, documentation 4 | 5 | =========================================================== 6 | ``commit`` -- Create a new image from a container's changes 7 | =========================================================== 8 | 9 | :: 10 | 11 | Usage: docker commit [OPTIONS] CONTAINER [REPOSITORY [TAG]] 12 | 13 | Create a new image from a container's changes 14 | 15 | -m="": Commit message 16 | -author="": Author (eg. "John Hannibal Smith " 17 | -run="": Config automatically applied when the image is run. "+`(ex: {"Cmd": ["cat", "/world"], "PortSpecs": ["22"]}') 18 | 19 | Full -run example:: 20 | 21 | {"Hostname": "", 22 | "User": "", 23 | "CpuShares": 0, 24 | "Memory": 0, 25 | "MemorySwap": 0, 26 | "PortSpecs": ["22", "80", "443"], 27 | "Tty": true, 28 | "OpenStdin": true, 29 | "StdinOnce": true, 30 | "Env": ["FOO=BAR", "FOO2=BAR2"], 31 | "Cmd": ["cat", "-e", "/etc/resolv.conf"], 32 | "Dns": ["8.8.8.8", "8.8.4.4"]} 33 | -------------------------------------------------------------------------------- /hack/PRINCIPLES.md: -------------------------------------------------------------------------------- 1 | # Docker principles 2 | 3 | In the design and development of Docker we try to follow these principles: 4 | 5 | (Work in progress) 6 | 7 | * Don't try to replace every tool. Instead, be an ingredient to improve them. 8 | * Less code is better. 9 | * Less components is better. Do you really need to add one more class? 10 | * 50 lines of straightforward, readable code is better than 10 lines of magic that nobody can understand. 11 | * Don't do later what you can do now. "//FIXME: refactor" is not acceptable in new code. 12 | * When hesitating between 2 options, choose the one that is easier to reverse. 13 | * No is temporary, Yes is forever. If you're not sure about a new feature, say no. You can change your mind later. 14 | * Containers must be portable to the greatest possible number of machines. Be suspicious of any change which makes machines less interchangeable. 15 | * The less moving parts in a container, the better. 16 | * Don't merge it unless you document it. 17 | * Don't document it unless you can keep it up-to-date. 18 | * Don't merge it unless you test it! 19 | * Everyone's problem is slightly different. Focus on the part that is the same for everyone, and solve that. 20 | -------------------------------------------------------------------------------- /packaging/ubuntu/README.ubuntu: -------------------------------------------------------------------------------- 1 | Docker on Ubuntu 2 | ================ 3 | 4 | The easiest way to get docker up and running natively on Ubuntu is installing 5 | it from its official PPA:: 6 | 7 | sudo sh -c "echo 'deb http://ppa.launchpad.net/dotcloud/lxc-docker/ubuntu precise main' >>/etc/apt/sources.list" 8 | sudo apt-get update 9 | sudo apt-get install lxc-docker 10 | 11 | 12 | Building docker package 13 | ~~~~~~~~~~~~~~~~~~~~~~~ 14 | 15 | The building process is shared by both, developers and maintainers. If you are 16 | a developer, the Makefile will stop with exit status 2 right before signing 17 | the built packages. 18 | 19 | Assuming you are working on an Ubuntu 12.04 TLS system :: 20 | 21 | # Download a fresh copy of the docker project 22 | git clone https://github.com/dotcloud/docker.git 23 | cd docker 24 | 25 | # Get building dependencies 26 | sudo apt-get update; sudo apt-get install -y debhelper autotools-dev devscripts golang 27 | 28 | # Make the ubuntu package 29 | (cd packaging/ubuntu; make ubuntu) 30 | 31 | 32 | Install docker built package 33 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 34 | 35 | :: 36 | 37 | sudo dpkg -i lxc-docker_*_amd64.deb; sudo apt-get install -f -y 38 | -------------------------------------------------------------------------------- /testing/README.rst: -------------------------------------------------------------------------------- 1 | ======= 2 | testing 3 | ======= 4 | 5 | This directory contains testing related files. 6 | 7 | 8 | Buildbot 9 | ======== 10 | 11 | Buildbot is a continuous integration system designed to automate the 12 | build/test cycle. By automatically rebuilding and testing the tree each time 13 | something has changed, build problems are pinpointed quickly, before other 14 | developers are inconvenienced by the failure. 15 | 16 | We are running buildbot in an AWS instance to verify docker passes all tests 17 | when commits get pushed to the master branch. 18 | 19 | You can check docker's buildbot instance at http://docker-ci.dotcloud.com/waterfall 20 | 21 | 22 | Deployment 23 | ~~~~~~~~~~ 24 | 25 | :: 26 | 27 | # Define AWS credential environment variables 28 | export AWS_ACCESS_KEY_ID=xxxxxxxxxxxx 29 | export AWS_SECRET_ACCESS_KEY=xxxxxxxxxxxx 30 | export AWS_KEYPAIR_NAME=xxxxxxxxxxxx 31 | export AWS_SSH_PRIVKEY=xxxxxxxxxxxx 32 | 33 | # Checkout docker 34 | git clone git://github.com/dotcloud/docker.git 35 | 36 | # Deploy docker on AWS 37 | cd docker/testing 38 | vagrant up --provider=aws 39 | 40 | 41 | Buildbot AWS dependencies 42 | ------------------------- 43 | 44 | vagrant, virtualbox packages and vagrant aws plugin 45 | -------------------------------------------------------------------------------- /packaging/debian/changelog: -------------------------------------------------------------------------------- 1 | lxc-docker (0.3.4-1) UNRELEASED; urgency=low 2 | - Builder: 'docker build' builds a container, layer by layer, from a source repository containing a Dockerfile 3 | - Builder: 'docker build -t FOO' applies the tag FOO to the newly built container. 4 | - Runtime: interactive TTYs correctly handle window resize 5 | - Runtime: fix how configuration is merged between layers 6 | - Remote API: split stdout and stderr on 'docker run' 7 | - Remote API: optionally listen on a different IP and port (use at your own risk) 8 | - Documentation: improved install instructions. 9 | 10 | -- dotCloud Thu, 30 May 2013 00:00:00 -0700 11 | 12 | lxc-docker (0.3.2-1) UNRELEASED; urgency=low 13 | - Runtime: Store the actual archive on commit 14 | - Registry: Improve the checksum process 15 | - Registry: Use the size to have a good progress bar while pushing 16 | - Registry: Use the actual archive if it exists in order to speed up the push 17 | - Registry: Fix error 400 on push 18 | 19 | -- Daniel Mizyrycki Sun, 12 May 2013 00:00:00 -0700 20 | 21 | 22 | lxc-docker (0.2.0-1) UNRELEASED; urgency=low 23 | 24 | - Pre-release (Closes: #706060) 25 | 26 | -- Daniel Mizyrycki Fri, 26 Apr 2013 23:41:29 -0700 27 | 28 | -------------------------------------------------------------------------------- /hack/fmt-check.hook: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # This pre-commit hook will abort if a committed file doesn't pass gofmt. 4 | # By Even Shaw 5 | # http://github.com/edsrzf/gofmt-git-hook 6 | 7 | test_fmt() { 8 | hash gofmt 2>&- || { echo >&2 "gofmt not in PATH."; exit 1; } 9 | IFS=' 10 | ' 11 | for file in `git diff --cached --name-only --diff-filter=ACM | grep '\.go$'` 12 | do 13 | output=`git cat-file -p :$file | gofmt -l 2>&1` 14 | if test $? -ne 0 15 | then 16 | output=`echo "$output" | sed "s,,$file,"` 17 | syntaxerrors="${list}${output}\n" 18 | elif test -n "$output" 19 | then 20 | list="${list}${file}\n" 21 | fi 22 | done 23 | exitcode=0 24 | if test -n "$syntaxerrors" 25 | then 26 | echo >&2 "gofmt found syntax errors:" 27 | printf "$syntaxerrors" 28 | exitcode=1 29 | fi 30 | if test -n "$list" 31 | then 32 | echo >&2 "gofmt needs to format these files (run gofmt -w and git add):" 33 | printf "$list" 34 | exitcode=1 35 | fi 36 | exit $exitcode 37 | } 38 | 39 | case "$1" in 40 | --about ) 41 | echo "Check Go code formatting" 42 | ;; 43 | * ) 44 | test_fmt 45 | ;; 46 | esac 47 | -------------------------------------------------------------------------------- /docs/sources/commandline/cli.rst: -------------------------------------------------------------------------------- 1 | :title: Command Line Interface 2 | :description: Docker's CLI command description and usage 3 | :keywords: Docker, Docker documentation, CLI, command line 4 | 5 | .. _cli: 6 | 7 | Overview 8 | ====================== 9 | 10 | Docker Usage 11 | ~~~~~~~~~~~~ 12 | 13 | To list available commands, either run ``docker`` with no parameters or execute 14 | ``docker help``:: 15 | 16 | $ docker 17 | Usage: docker [OPTIONS] COMMAND [arg...] 18 | -H=[tcp://127.0.0.1:4243]: tcp://host:port to bind/connect to or unix://path/to/socket to use 19 | 20 | A self-sufficient runtime for linux containers. 21 | 22 | ... 23 | 24 | Available Commands 25 | ~~~~~~~~~~~~~~~~~~ 26 | 27 | .. toctree:: 28 | :maxdepth: 2 29 | 30 | command/attach 31 | command/build 32 | command/commit 33 | command/diff 34 | command/export 35 | command/history 36 | command/images 37 | command/import 38 | command/info 39 | command/inspect 40 | command/kill 41 | command/login 42 | command/logs 43 | command/port 44 | command/ps 45 | command/pull 46 | command/push 47 | command/restart 48 | command/rm 49 | command/rmi 50 | command/run 51 | command/search 52 | command/start 53 | command/stop 54 | command/tag 55 | command/version 56 | command/wait 57 | -------------------------------------------------------------------------------- /testing/buildbot/setup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Setup of buildbot configuration. Package installation is being done by 4 | # Vagrantfile 5 | # Dependencies: buildbot, buildbot-slave, supervisor 6 | 7 | USER=$1 8 | CFG_PATH=$2 9 | BUILDBOT_PATH="/data/buildbot" 10 | DOCKER_PATH="/data/docker" 11 | SLAVE_NAME="buildworker" 12 | SLAVE_SOCKET="localhost:9989" 13 | BUILDBOT_PWD="pass-docker" 14 | export PATH="/bin:sbin:/usr/bin:/usr/sbin:/usr/local/bin" 15 | 16 | function run { su $USER -c "$1"; } 17 | 18 | # Exit if buildbot has already been installed 19 | [ -d "$BUILDBOT_PATH" ] && exit 0 20 | 21 | # Setup buildbot 22 | run "mkdir -p $BUILDBOT_PATH" 23 | cd $BUILDBOT_PATH 24 | run "buildbot create-master master" 25 | run "cp $CFG_PATH/master.cfg master" 26 | run "sed -i -E 's#(DOCKER_PATH = ).+#\1\"$DOCKER_PATH\"#' master/master.cfg" 27 | run "buildslave create-slave slave $SLAVE_SOCKET $SLAVE_NAME $BUILDBOT_PWD" 28 | 29 | # Allow buildbot subprocesses (docker tests) to properly run in containers, 30 | # in particular with docker -u 31 | run "sed -i 's/^umask = None/umask = 000/' slave/buildbot.tac" 32 | 33 | # Setup supervisor 34 | cp $CFG_PATH/buildbot.conf /etc/supervisor/conf.d/buildbot.conf 35 | sed -i -E "s/^chmod=0700.+/chmod=0770\nchown=root:$USER/" /etc/supervisor/supervisord.conf 36 | kill -HUP $(pgrep -f "/usr/bin/python /usr/bin/supervisord") 37 | -------------------------------------------------------------------------------- /term/termios_linux.go: -------------------------------------------------------------------------------- 1 | package term 2 | 3 | import ( 4 | "syscall" 5 | "unsafe" 6 | ) 7 | 8 | const ( 9 | getTermios = syscall.TCGETS 10 | setTermios = syscall.TCSETS 11 | ) 12 | 13 | type Termios struct { 14 | Iflag uint32 15 | Oflag uint32 16 | Cflag uint32 17 | Lflag uint32 18 | Cc [20]byte 19 | Ispeed uint32 20 | Ospeed uint32 21 | } 22 | 23 | // MakeRaw put the terminal connected to the given file descriptor into raw 24 | // mode and returns the previous state of the terminal so that it can be 25 | // restored. 26 | func MakeRaw(fd uintptr) (*State, error) { 27 | var oldState State 28 | if _, _, err := syscall.Syscall(syscall.SYS_IOCTL, fd, getTermios, uintptr(unsafe.Pointer(&oldState.termios))); err != 0 { 29 | return nil, err 30 | } 31 | 32 | newState := oldState.termios 33 | 34 | newState.Iflag &^= (syscall.IGNBRK | syscall.BRKINT | syscall.PARMRK | syscall.ISTRIP | syscall.INLCR | syscall.IGNCR | syscall.ICRNL | syscall.IXON) 35 | newState.Oflag &^= syscall.OPOST 36 | newState.Lflag &^= (syscall.ECHO | syscall.ECHONL | syscall.ICANON | syscall.ISIG | syscall.IEXTEN) 37 | newState.Cflag &^= (syscall.CSIZE | syscall.PARENB) 38 | newState.Cflag |= syscall.CS8 39 | 40 | if _, _, err := syscall.Syscall(syscall.SYS_IOCTL, fd, setTermios, uintptr(unsafe.Pointer(&newState))); err != 0 { 41 | return nil, err 42 | } 43 | return &oldState, nil 44 | } 45 | -------------------------------------------------------------------------------- /docs/theme/docker/static/js/docs.js: -------------------------------------------------------------------------------- 1 | 2 | $(function(){ 3 | 4 | // init multi-vers stuff 5 | $('.tabswitcher').each(function(i, multi_vers){ 6 | var tabs = $('
    '); 7 | $(multi_vers).prepend(tabs); 8 | $(multi_vers).children('.tab').each(function(j, vers_content){ 9 | vers = $(vers_content).children(':first').text(); 10 | var id = 'multi_vers_' + '_' + i + '_' + j; 11 | $(vers_content).attr('id', id); 12 | $(tabs).append('
  • ' + vers + '
  • '); 13 | }); 14 | }); 15 | $( ".tabswitcher" ).tabs(); 16 | 17 | // sidebar acordian-ing 18 | // don't apply on last object (it should be the FAQ) 19 | $('nav > ul > li > a').not(':last').click(function(){ 20 | if ($(this).parent().hasClass('current')) { 21 | $(this).parent().children('ul').slideUp(200, function() { 22 | $(this).parent().removeClass('current'); // toggle after effect 23 | }); 24 | } else { 25 | $('nav > ul > li > ul').slideUp(100); 26 | var current = $(this); 27 | setTimeout(function() { 28 | $('nav > ul > li').removeClass('current'); 29 | current.parent().addClass('current'); // toggle before effect 30 | current.parent().children('ul').hide(); 31 | current.parent().children('ul').slideDown(200); 32 | }, 100); 33 | } 34 | return false; 35 | }); 36 | 37 | }); -------------------------------------------------------------------------------- /term/termios_darwin.go: -------------------------------------------------------------------------------- 1 | package term 2 | 3 | import ( 4 | "syscall" 5 | "unsafe" 6 | ) 7 | 8 | const ( 9 | getTermios = syscall.TIOCGETA 10 | setTermios = syscall.TIOCSETA 11 | 12 | ECHO = 0x00000008 13 | ONLCR = 0x2 14 | ISTRIP = 0x20 15 | INLCR = 0x40 16 | ISIG = 0x80 17 | IGNCR = 0x80 18 | ICANON = 0x100 19 | ICRNL = 0x100 20 | IXOFF = 0x400 21 | IXON = 0x200 22 | ) 23 | 24 | type Termios struct { 25 | Iflag uint64 26 | Oflag uint64 27 | Cflag uint64 28 | Lflag uint64 29 | Cc [20]byte 30 | Ispeed uint64 31 | Ospeed uint64 32 | } 33 | 34 | // MakeRaw put the terminal connected to the given file descriptor into raw 35 | // mode and returns the previous state of the terminal so that it can be 36 | // restored. 37 | func MakeRaw(fd uintptr) (*State, error) { 38 | var oldState State 39 | if _, _, err := syscall.Syscall(syscall.SYS_IOCTL, fd, uintptr(getTermios), uintptr(unsafe.Pointer(&oldState.termios))); err != 0 { 40 | return nil, err 41 | } 42 | 43 | newState := oldState.termios 44 | newState.Iflag &^= (ISTRIP | INLCR | IGNCR | IXON | IXOFF) 45 | newState.Iflag |= ICRNL 46 | newState.Oflag |= ONLCR 47 | newState.Lflag &^= (ECHO | ICANON | ISIG) 48 | 49 | if _, _, err := syscall.Syscall(syscall.SYS_IOCTL, fd, uintptr(setTermios), uintptr(unsafe.Pointer(&newState))); err != 0 { 50 | return nil, err 51 | } 52 | 53 | return &oldState, nil 54 | } 55 | -------------------------------------------------------------------------------- /contrib/mkimage-debian.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | 4 | # these should match the names found at http://www.debian.org/releases/ 5 | stableSuite='wheezy' 6 | testingSuite='jessie' 7 | unstableSuite='sid' 8 | 9 | variant='minbase' 10 | include='iproute,iputils-ping' 11 | 12 | repo="$1" 13 | suite="${2:-$stableSuite}" 14 | mirror="${3:-}" # stick to the default debootstrap mirror if one is not provided 15 | 16 | if [ ! "$repo" ]; then 17 | echo >&2 "usage: $0 repo [suite [mirror]]" 18 | echo >&2 " ie: $0 tianon/debian squeeze" 19 | exit 1 20 | fi 21 | 22 | target="/tmp/docker-rootfs-debian-$suite-$$-$RANDOM" 23 | 24 | cd "$(dirname "$(readlink -f "$BASH_SOURCE")")" 25 | returnTo="$(pwd -P)" 26 | 27 | set -x 28 | 29 | # bootstrap 30 | mkdir -p "$target" 31 | sudo debootstrap --verbose --variant="$variant" --include="$include" "$suite" "$target" "$mirror" 32 | 33 | cd "$target" 34 | 35 | # create the image 36 | img=$(sudo tar -c . | docker import -) 37 | 38 | # tag suite 39 | docker tag $img $repo $suite 40 | 41 | # test the image 42 | docker run -i -t $repo:$suite echo success 43 | 44 | if [ "$suite" = "$stableSuite" -o "$suite" = 'stable' ]; then 45 | # tag latest 46 | docker tag $img $repo latest 47 | 48 | # tag the specific debian release version 49 | ver=$(docker run $repo:$suite cat /etc/debian_version) 50 | docker tag $img $repo $ver 51 | fi 52 | 53 | # cleanup 54 | cd "$returnTo" 55 | sudo rm -rf "$target" 56 | -------------------------------------------------------------------------------- /.mailmap: -------------------------------------------------------------------------------- 1 | # Generate AUTHORS: git log --all --format='%aN <%aE>' | sort -uf | grep -v vagrant-ubuntu-12 2 | 3 | 4 | 5 | Guillaume J. Charmes 6 | 7 | 8 | 9 | Thatcher Peskens dhrp 10 | Thatcher Peskens dhrp 11 | Jérôme Petazzoni jpetazzo 12 | Jérôme Petazzoni 13 | Joffrey F 14 | 15 | Tim Terhorst 16 | Andy Smith 17 | 18 | 19 | 20 | 21 | Thatcher Peskens 22 | 23 | Walter Stanish 24 | 25 | Roberto Hashioka 26 | -------------------------------------------------------------------------------- /hack/getmaintainer.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [ $# -ne 1 ]; then 4 | echo >&2 "Usage: $0 PATH" 5 | echo >&2 "Show the primary and secondary maintainers for a given path" 6 | exit 1 7 | fi 8 | 9 | set -e 10 | 11 | DEST=$1 12 | DESTFILE="" 13 | if [ ! -d $DEST ]; then 14 | DESTFILE=$(basename $DEST) 15 | DEST=$(dirname $DEST) 16 | fi 17 | 18 | MAINTAINERS=() 19 | cd $DEST 20 | while true; do 21 | if [ -e ./MAINTAINERS ]; then 22 | { 23 | while read line; do 24 | re='^([^:]*): *(.*)$' 25 | file=$(echo $line | sed -E -n "s/$re/\1/p") 26 | if [ ! -z "$file" ]; then 27 | if [ "$file" = "$DESTFILE" ]; then 28 | echo "Override: $line" 29 | maintainer=$(echo $line | sed -E -n "s/$re/\2/p") 30 | MAINTAINERS=("$maintainer" "${MAINTAINERS[@]}") 31 | fi 32 | else 33 | MAINTAINERS+=("$line"); 34 | fi 35 | done; 36 | } < MAINTAINERS 37 | fi 38 | if [ -d .git ]; then 39 | break 40 | fi 41 | if [ "$(pwd)" = "/" ]; then 42 | break 43 | fi 44 | cd .. 45 | done 46 | 47 | PRIMARY="${MAINTAINERS[0]}" 48 | PRIMARY_FIRSTNAME=$(echo $PRIMARY | cut -d' ' -f1) 49 | 50 | firstname() { 51 | echo $1 | cut -d' ' -f1 52 | } 53 | 54 | echo "--- $PRIMARY is the PRIMARY MAINTAINER of $1. Assign pull requests to him." 55 | echo "$(firstname $PRIMARY) may assign pull requests to the following secondary maintainers:" 56 | for SECONDARY in "${MAINTAINERS[@]:1}"; do 57 | echo "--- $SECONDARY" 58 | done 59 | -------------------------------------------------------------------------------- /docs/sources/examples/hello_world.rst: -------------------------------------------------------------------------------- 1 | :title: Hello world example 2 | :description: A simple hello world example with Docker 3 | :keywords: docker, example, hello world 4 | 5 | .. _hello_world: 6 | 7 | Hello World 8 | =========== 9 | 10 | .. include:: example_header.inc 11 | 12 | This is the most basic example available for using Docker. 13 | 14 | Download the base container 15 | 16 | .. code-block:: bash 17 | 18 | # Download a base image 19 | docker pull base 20 | 21 | The *base* image is a minimal *ubuntu* based container, alternatively you can select *busybox*, a bare 22 | minimal linux system. The images are retrieved from the docker repository. 23 | 24 | 25 | .. code-block:: bash 26 | 27 | #run a simple echo command, that will echo hello world back to the console over standard out. 28 | docker run base /bin/echo hello world 29 | 30 | **Explanation:** 31 | 32 | - **"docker run"** run a command in a new container 33 | - **"base"** is the image we want to run the command inside of. 34 | - **"/bin/echo"** is the command we want to run in the container 35 | - **"hello world"** is the input for the echo command 36 | 37 | 38 | 39 | **Video:** 40 | 41 | See the example in action 42 | 43 | .. raw:: html 44 | 45 |
    46 | 47 |
    48 | 49 | 50 | Continue to the :ref:`hello_world_daemon` example. -------------------------------------------------------------------------------- /tags_test.go: -------------------------------------------------------------------------------- 1 | package docker 2 | 3 | import ( 4 | "testing" 5 | ) 6 | 7 | func TestLookupImage(t *testing.T) { 8 | runtime, err := newTestRuntime() 9 | if err != nil { 10 | t.Fatal(err) 11 | } 12 | defer nuke(runtime) 13 | 14 | if img, err := runtime.repositories.LookupImage(unitTestImageName); err != nil { 15 | t.Fatal(err) 16 | } else if img == nil { 17 | t.Errorf("Expected 1 image, none found") 18 | } 19 | 20 | if img, err := runtime.repositories.LookupImage(unitTestImageName + ":" + DEFAULTTAG); err != nil { 21 | t.Fatal(err) 22 | } else if img == nil { 23 | t.Errorf("Expected 1 image, none found") 24 | } 25 | 26 | if img, err := runtime.repositories.LookupImage(unitTestImageName + ":" + "fail"); err == nil { 27 | t.Errorf("Expected error, none found") 28 | } else if img != nil { 29 | t.Errorf("Expected 0 image, 1 found") 30 | } 31 | 32 | if img, err := runtime.repositories.LookupImage("fail:fail"); err == nil { 33 | t.Errorf("Expected error, none found") 34 | } else if img != nil { 35 | t.Errorf("Expected 0 image, 1 found") 36 | } 37 | 38 | if img, err := runtime.repositories.LookupImage(unitTestImageId); err != nil { 39 | t.Fatal(err) 40 | } else if img == nil { 41 | t.Errorf("Expected 1 image, none found") 42 | } 43 | 44 | if img, err := runtime.repositories.LookupImage(unitTestImageName + ":" + unitTestImageId); err != nil { 45 | t.Fatal(err) 46 | } else if img == nil { 47 | t.Errorf("Expected 1 image, none found") 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /docs/sources/installation/upgrading.rst: -------------------------------------------------------------------------------- 1 | :title: Upgrading 2 | :description: These instructions are for upgrading Docker 3 | :keywords: Docker, Docker documentation, upgrading docker, upgrade 4 | 5 | .. _upgrading: 6 | 7 | Upgrading 8 | ============ 9 | 10 | **These instructions are for upgrading Docker** 11 | 12 | 13 | After normal installation 14 | ------------------------- 15 | 16 | If you installed Docker normally using apt-get or used Vagrant, use apt-get to upgrade. 17 | 18 | .. code-block:: bash 19 | 20 | # update your sources list 21 | sudo apt-get update 22 | 23 | # install the latest 24 | sudo apt-get install lxc-docker 25 | 26 | 27 | After manual installation 28 | ------------------------- 29 | 30 | If you installed the Docker binary 31 | 32 | 33 | .. code-block:: bash 34 | 35 | # kill the running docker daemon 36 | killall docker 37 | 38 | 39 | .. code-block:: bash 40 | 41 | # get the latest binary 42 | wget http://get.docker.io/builds/Linux/x86_64/docker-latest.tgz 43 | 44 | 45 | .. code-block:: bash 46 | 47 | # Unpack it to your current dir 48 | tar -xf docker-latest.tgz 49 | 50 | 51 | Start docker in daemon mode (-d) and disconnect (&) starting ./docker will start the version in your current dir rather than a version which 52 | might reside in your path. 53 | 54 | .. code-block:: bash 55 | 56 | # start the new version 57 | sudo ./docker -d & 58 | 59 | 60 | Alternatively you can replace the docker binary in ``/usr/local/bin`` 61 | -------------------------------------------------------------------------------- /mount.go: -------------------------------------------------------------------------------- 1 | package docker 2 | 3 | import ( 4 | "fmt" 5 | "github.com/dotcloud/docker/utils" 6 | "os" 7 | "os/exec" 8 | "path/filepath" 9 | "syscall" 10 | "time" 11 | ) 12 | 13 | func Unmount(target string) error { 14 | if err := exec.Command("auplink", target, "flush").Run(); err != nil { 15 | utils.Debugf("[warning]: couldn't run auplink before unmount: %s", err) 16 | } 17 | if err := syscall.Unmount(target, 0); err != nil { 18 | return err 19 | } 20 | // Even though we just unmounted the filesystem, AUFS will prevent deleting the mntpoint 21 | // for some time. We'll just keep retrying until it succeeds. 22 | for retries := 0; retries < 1000; retries++ { 23 | err := os.Remove(target) 24 | if err == nil { 25 | // rm mntpoint succeeded 26 | return nil 27 | } 28 | if os.IsNotExist(err) { 29 | // mntpoint doesn't exist anymore. Success. 30 | return nil 31 | } 32 | // fmt.Printf("(%v) Remove %v returned: %v\n", retries, target, err) 33 | time.Sleep(10 * time.Millisecond) 34 | } 35 | return fmt.Errorf("Umount: Failed to umount %v", target) 36 | } 37 | 38 | func Mounted(mountpoint string) (bool, error) { 39 | mntpoint, err := os.Stat(mountpoint) 40 | if err != nil { 41 | if os.IsNotExist(err) { 42 | return false, nil 43 | } 44 | return false, err 45 | } 46 | parent, err := os.Stat(filepath.Join(mountpoint, "..")) 47 | if err != nil { 48 | return false, err 49 | } 50 | mntpointSt := mntpoint.Sys().(*syscall.Stat_t) 51 | parentSt := parent.Sys().(*syscall.Stat_t) 52 | return mntpointSt.Dev != parentSt.Dev, nil 53 | } 54 | -------------------------------------------------------------------------------- /FIXME: -------------------------------------------------------------------------------- 1 | 2 | ## FIXME 3 | 4 | This file is a loose collection of things to improve in the codebase, for the internal 5 | use of the maintainers. 6 | 7 | They are not big enough to be in the roadmap, not user-facing enough to be github issues, 8 | and not important enough to be discussed in the mailing list. 9 | 10 | They are just like FIXME comments in the source code, except we're not sure where in the source 11 | to put them - so we put them here :) 12 | 13 | 14 | * Merge Runtime, Server and Builder into Runtime 15 | * Run linter on codebase 16 | * Unify build commands and regular commands 17 | * Move source code into src/ subdir for clarity 18 | * Clean up the Makefile, it's a mess 19 | * docker build: on non-existent local path for ADD, don't show full absolute path on the host 20 | * mount into /dockerinit rather than /sbin/init 21 | * docker tag foo REPO:TAG 22 | * use size header for progress bar in pull 23 | * Clean up context upload in build!!! 24 | * Parallel pull 25 | * Ensure /proc/sys/net/ipv4/ip_forward is 1 26 | * Force DNS to public! 27 | * Always generate a resolv.conf per container, to avoid changing resolv.conf under thne container's feet 28 | * Save metadata with import/export 29 | * Upgrade dockerd without stopping containers 30 | * bring back git revision info, looks like it was lost 31 | * Simple command to remove all untagged images 32 | * Simple command to clean up containers for disk space 33 | * Caching after an ADD 34 | * entry point config 35 | * bring back git revision info, looks like it was lost 36 | * Clean up the ProgressReader api, it's a PITA to use 37 | -------------------------------------------------------------------------------- /packaging/ubuntu/maintainer.ubuntu: -------------------------------------------------------------------------------- 1 | Maintainer duty 2 | =============== 3 | 4 | Ubuntu allows developers to use their PPA (Personal Package Archive) 5 | repository. This is very convenient for the users as they just need to add 6 | the PPA address, update their package database and use the apt-get tool. 7 | 8 | For now, the official lxc-docker package is located on launchpad and can be 9 | accessed adding the following line to /etc/apt/sources.list :: 10 | 11 | 12 | deb http://ppa.launchpad.net/dotcloud/lxc-docker/ubuntu precise main 13 | 14 | 15 | Releasing a new package 16 | ~~~~~~~~~~~~~~~~~~~~~~~ 17 | 18 | The most relevant information to update is the packaging/ubuntu/changelog file: 19 | Each new release should create a new first paragraph with new release version, 20 | changes, and the maintainer information. The core of this paragraph is 21 | located on CHANGELOG.md. Make sure to transcribe it and translate the formats 22 | (eg: packaging/ubuntu/changelog uses 2 spaces for body change descriptions 23 | instead of 1 space from CHANGELOG.md) 24 | 25 | Assuming your PPA GPG signing key is on /media/usbdrive/docker.key, load it 26 | into the GPG_KEY environment variable with:: 27 | 28 | export GPG_KEY=`cat /media/usbdrive/docker.key` 29 | 30 | 31 | After this is done and you are ready to upload the package to the PPA, you have 32 | a couple of choices: 33 | 34 | * Follow packaging/ubuntu/README.ubuntu to generate the actual source packages 35 | and upload them to the PPA 36 | 37 | * Let vagrant do all the work for you:: 38 | 39 | ( cd docker/packaging/ubuntu; vagrant up ) 40 | -------------------------------------------------------------------------------- /docs/sources/commandline/command/import.rst: -------------------------------------------------------------------------------- 1 | :title: Import Command 2 | :description: Create a new filesystem image from the contents of a tarball 3 | :keywords: import, tarball, docker, url, documentation 4 | 5 | ========================================================================== 6 | ``import`` -- Create a new filesystem image from the contents of a tarball 7 | ========================================================================== 8 | 9 | :: 10 | 11 | Usage: docker import URL|- [REPOSITORY [TAG]] 12 | 13 | Create a new filesystem image from the contents of a tarball 14 | 15 | At this time, the URL must start with ``http`` and point to a single file archive (.tar, .tar.gz, .bzip) 16 | containing a root filesystem. If you would like to import from a local directory or archive, 17 | you can use the ``-`` parameter to take the data from standard in. 18 | 19 | Examples 20 | -------- 21 | 22 | Import from a remote location 23 | ............................. 24 | 25 | ``$ docker import http://example.com/exampleimage.tgz exampleimagerepo`` 26 | 27 | Import from a local file 28 | ........................ 29 | 30 | Import to docker via pipe and standard in 31 | 32 | ``$ cat exampleimage.tgz | docker import - exampleimagelocal`` 33 | 34 | Import from a local directory 35 | ............................. 36 | 37 | ``$ sudo tar -c . | docker import - exampleimagedir`` 38 | 39 | Note the ``sudo`` in this example -- you must preserve the ownership of the files (especially root ownership) 40 | during the archiving with tar. If you are not root (or sudo) when you tar, then the ownerships might not get preserved. 41 | -------------------------------------------------------------------------------- /hack/Vagrantfile: -------------------------------------------------------------------------------- 1 | # -*- mode: ruby -*- 2 | # vi: set ft=ruby : 3 | 4 | BOX_NAME = "ubuntu-dev" 5 | BOX_URI = "http://cloud-images.ubuntu.com/raring/current/raring-server-cloudimg-vagrant-amd64-disk1.box" 6 | VM_IP = "192.168.33.21" 7 | USER = "vagrant" 8 | GOPATH = "/data/docker" 9 | DOCKER_PATH = "#{GOPATH}/src/github.com/dotcloud/docker" 10 | CFG_PATH = "#{DOCKER_PATH}/hack/environment" 11 | BUILDBOT_PATH = "/data/buildbot" 12 | 13 | Vagrant::Config.run do |config| 14 | # Setup virtual machine box 15 | config.vm.box = BOX_NAME 16 | config.vm.box_url = BOX_URI 17 | config.vm.share_folder "v-data", DOCKER_PATH, "#{File.dirname(__FILE__)}/.." 18 | config.vm.network :hostonly, VM_IP 19 | # Stop if deployment has been done 20 | config.vm.provision :shell, :inline => "[ ! -f /usr/bin/git ]" 21 | # Touch for makefile 22 | pkg_cmd = "touch #{DOCKER_PATH}; " 23 | # Install docker dependencies 24 | pkg_cmd << "export DEBIAN_FRONTEND=noninteractive; apt-get -qq update; " \ 25 | "apt-get install -q -y lxc git aufs-tools golang make linux-image-extra-`uname -r`; " \ 26 | "chown -R #{USER}.#{USER} #{GOPATH}; " \ 27 | "install -m 0664 #{CFG_PATH}/bash_profile /home/#{USER}/.bash_profile" 28 | config.vm.provision :shell, :inline => pkg_cmd 29 | # Deploy buildbot CI 30 | pkg_cmd = "apt-get install -q -y python-dev python-pip supervisor; " \ 31 | "pip install -r #{CFG_PATH}/requirements.txt; " \ 32 | "chown #{USER}.#{USER} /data; cd /data; " \ 33 | "#{CFG_PATH}/setup.sh #{USER} #{GOPATH} #{DOCKER_PATH} #{CFG_PATH} #{BUILDBOT_PATH}" 34 | config.vm.provision :shell, :inline => pkg_cmd 35 | end 36 | -------------------------------------------------------------------------------- /docs/sources/contributing/devenvironment.rst: -------------------------------------------------------------------------------- 1 | :title: Setting Up a Dev Environment 2 | :description: Guides on how to contribute to docker 3 | :keywords: Docker, documentation, developers, contributing, dev environment 4 | 5 | Setting Up a Dev Environment 6 | ============================ 7 | 8 | Instructions that have been verified to work on Ubuntu Precise 12.04 (LTS) (64-bit), 9 | 10 | 11 | Dependencies 12 | ------------ 13 | 14 | **Linux kernel 3.8** 15 | 16 | Due to a bug in LXC docker works best on the 3.8 kernel. Precise comes with a 3.2 kernel, so we need to upgrade it. The kernel we install comes with AUFS built in. 17 | 18 | 19 | .. code-block:: bash 20 | 21 | # install the backported kernel 22 | sudo apt-get update && sudo apt-get install linux-image-generic-lts-raring 23 | 24 | # reboot 25 | sudo reboot 26 | 27 | 28 | Installation 29 | ------------ 30 | 31 | .. code-block:: bash 32 | 33 | sudo apt-get install python-software-properties 34 | sudo add-apt-repository ppa:gophers/go 35 | sudo apt-get update 36 | sudo apt-get -y install lxc xz-utils curl golang-stable git aufs-tools 37 | 38 | export GOPATH=~/go/ 39 | export PATH=$GOPATH/bin:$PATH 40 | 41 | mkdir -p $GOPATH/src/github.com/dotcloud 42 | cd $GOPATH/src/github.com/dotcloud 43 | git clone git://github.com/dotcloud/docker.git 44 | cd docker 45 | 46 | go get -v github.com/dotcloud/docker/... 47 | go install -v github.com/dotcloud/docker/... 48 | 49 | 50 | Then run the docker daemon, 51 | 52 | .. code-block:: bash 53 | 54 | sudo $GOPATH/bin/docker -d 55 | 56 | 57 | Run the ``go install`` command (above) to recompile docker. 58 | -------------------------------------------------------------------------------- /hack/environment/setup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Setup of buildbot configuration. Package installation is being done by 4 | # Vagrantfile 5 | # Dependencies: buildbot, buildbot-slave, supervisor 6 | 7 | USER=$1 8 | GOPATH=$2 9 | DOCKER_PATH=$3 10 | CFG_PATH=$4 11 | BUILDBOT_PATH=$5 12 | SLAVE_NAME="buildworker" 13 | SLAVE_SOCKET="localhost:9989" 14 | BUILDBOT_PWD="pass-docker" 15 | IP=$(sed -nE 's/VM_IP = "(.+)"/\1/p' ${DOCKER_PATH}/hack/Vagrantfile) 16 | export PATH="/bin:sbin:/usr/bin:/usr/sbin:/usr/local/bin" 17 | 18 | function run { su $USER -c "$1"; } 19 | 20 | # Exit if buildbot has already been installed 21 | [ -d "$BUILDBOT_PATH" ] && exit 0 22 | 23 | # Setup buildbot 24 | run "mkdir -p $BUILDBOT_PATH" 25 | cd $BUILDBOT_PATH 26 | run "buildbot create-master master" 27 | run "cp $CFG_PATH/master.cfg master" 28 | run "sed -i 's/localhost/$IP/' master/master.cfg" 29 | run "sed -i -E 's#(GOPATH = ).+#\1\"$GOPATH\"#' master/master.cfg" 30 | run "sed -i -E 's#(DOCKER_PATH = ).+#\1\"$DOCKER_PATH\"#' master/master.cfg" 31 | run "buildslave create-slave slave $SLAVE_SOCKET $SLAVE_NAME $BUILDBOT_PWD" 32 | 33 | # Allow buildbot subprocesses (docker tests) to properly run in containers, 34 | # in particular with docker -u 35 | run "sed -i 's/^umask = None/umask = 000/' slave/buildbot.tac" 36 | 37 | # Setup supervisor 38 | cp $CFG_PATH/buildbot.conf /etc/supervisor/conf.d/buildbot.conf 39 | sed -i -E "s/^chmod=0700.+/chmod=0770\nchown=root:$USER/" /etc/supervisor/supervisord.conf 40 | kill -HUP $(pgrep -f "/usr/bin/python /usr/bin/supervisord") 41 | 42 | # Add git hook 43 | cp $CFG_PATH/post-commit $DOCKER_PATH/.git/hooks 44 | sed -i "s/localhost/$IP/" $DOCKER_PATH/.git/hooks/post-commit 45 | 46 | -------------------------------------------------------------------------------- /docs/sources/installation/binaries.rst: -------------------------------------------------------------------------------- 1 | :title: Installation from Binaries 2 | :description: This instruction set is meant for hackers who want to try out Docker on a variety of environments. 3 | :keywords: binaries, installation, docker, documentation, linux 4 | 5 | .. _binaries: 6 | 7 | Binaries 8 | ======== 9 | 10 | **Please note this project is currently under heavy development. It should not be used in production.** 11 | 12 | **This instruction set is meant for hackers who want to try out Docker on a variety of environments.** 13 | 14 | Right now, the officially supported distributions are: 15 | 16 | - :ref:`ubuntu_precise` 17 | - :ref:`ubuntu_raring` 18 | 19 | 20 | But we know people have had success running it under 21 | 22 | - Debian 23 | - Suse 24 | - :ref:`arch_linux` 25 | 26 | 27 | Dependencies: 28 | ------------- 29 | 30 | * 3.8 Kernel (read more about :ref:`kernel`) 31 | * AUFS filesystem support 32 | * lxc 33 | * xz-utils 34 | 35 | Get the docker binary: 36 | ---------------------- 37 | 38 | .. code-block:: bash 39 | 40 | wget http://get.docker.io/builds/Linux/x86_64/docker-latest.tgz 41 | tar -xf docker-latest.tgz 42 | 43 | 44 | Run the docker daemon 45 | --------------------- 46 | 47 | .. code-block:: bash 48 | 49 | # start the docker in daemon mode from the directory you unpacked 50 | sudo ./docker -d & 51 | 52 | 53 | Run your first container! 54 | ------------------------- 55 | 56 | .. code-block:: bash 57 | 58 | # check your docker version 59 | ./docker version 60 | 61 | # run a container and open an interactive shell in the container 62 | ./docker run -i -t ubuntu /bin/bash 63 | 64 | 65 | 66 | Continue with the :ref:`hello_world` example. 67 | -------------------------------------------------------------------------------- /term/term.go: -------------------------------------------------------------------------------- 1 | package term 2 | 3 | import ( 4 | "os" 5 | "os/signal" 6 | "syscall" 7 | "unsafe" 8 | ) 9 | 10 | type State struct { 11 | termios Termios 12 | } 13 | 14 | type Winsize struct { 15 | Width uint16 16 | Height uint16 17 | x uint16 18 | y uint16 19 | } 20 | 21 | func GetWinsize(fd uintptr) (*Winsize, error) { 22 | ws := &Winsize{} 23 | _, _, err := syscall.Syscall(syscall.SYS_IOCTL, fd, uintptr(syscall.TIOCGWINSZ), uintptr(unsafe.Pointer(ws))) 24 | return ws, err 25 | } 26 | 27 | func SetWinsize(fd uintptr, ws *Winsize) error { 28 | _, _, err := syscall.Syscall(syscall.SYS_IOCTL, fd, uintptr(syscall.TIOCSWINSZ), uintptr(unsafe.Pointer(ws))) 29 | return err 30 | } 31 | 32 | // IsTerminal returns true if the given file descriptor is a terminal. 33 | func IsTerminal(fd uintptr) bool { 34 | var termios Termios 35 | _, _, err := syscall.Syscall(syscall.SYS_IOCTL, fd, uintptr(getTermios), uintptr(unsafe.Pointer(&termios))) 36 | return err == 0 37 | } 38 | 39 | // Restore restores the terminal connected to the given file descriptor to a 40 | // previous state. 41 | func Restore(fd uintptr, state *State) error { 42 | _, _, err := syscall.Syscall(syscall.SYS_IOCTL, fd, uintptr(setTermios), uintptr(unsafe.Pointer(&state.termios))) 43 | return err 44 | } 45 | 46 | func SetRawTerminal() (*State, error) { 47 | oldState, err := MakeRaw(os.Stdin.Fd()) 48 | if err != nil { 49 | return nil, err 50 | } 51 | c := make(chan os.Signal, 1) 52 | signal.Notify(c, os.Interrupt) 53 | go func() { 54 | _ = <-c 55 | Restore(os.Stdin.Fd(), oldState) 56 | os.Exit(0) 57 | }() 58 | return oldState, err 59 | } 60 | 61 | func RestoreTerminal(state *State) { 62 | Restore(os.Stdin.Fd(), state) 63 | } 64 | -------------------------------------------------------------------------------- /api_params.go: -------------------------------------------------------------------------------- 1 | package docker 2 | 3 | type APIHistory struct { 4 | ID string `json:"Id"` 5 | Tags []string `json:",omitempty"` 6 | Created int64 7 | CreatedBy string `json:",omitempty"` 8 | } 9 | 10 | type APIImages struct { 11 | Repository string `json:",omitempty"` 12 | Tag string `json:",omitempty"` 13 | ID string `json:"Id"` 14 | Created int64 15 | Size int64 16 | VirtualSize int64 17 | } 18 | 19 | type APIInfo struct { 20 | Debug bool 21 | Containers int 22 | Images int 23 | NFd int `json:",omitempty"` 24 | NGoroutines int `json:",omitempty"` 25 | MemoryLimit bool `json:",omitempty"` 26 | SwapLimit bool `json:",omitempty"` 27 | } 28 | 29 | type APIRmi struct { 30 | Deleted string `json:",omitempty"` 31 | Untagged string `json:",omitempty"` 32 | } 33 | 34 | type APIContainers struct { 35 | ID string `json:"Id"` 36 | Image string 37 | Command string 38 | Created int64 39 | Status string 40 | Ports string 41 | SizeRw int64 42 | SizeRootFs int64 43 | } 44 | 45 | type APISearch struct { 46 | Name string 47 | Description string 48 | } 49 | 50 | type APIID struct { 51 | ID string `json:"Id"` 52 | } 53 | 54 | type APIRun struct { 55 | ID string `json:"Id"` 56 | Warnings []string `json:",omitempty"` 57 | } 58 | 59 | type APIPort struct { 60 | Port string 61 | } 62 | 63 | type APIVersion struct { 64 | Version string 65 | GitCommit string `json:",omitempty"` 66 | GoVersion string `json:",omitempty"` 67 | } 68 | 69 | type APIWait struct { 70 | StatusCode int 71 | } 72 | 73 | type APIAuth struct { 74 | Status string 75 | } 76 | 77 | type APIImageConfig struct { 78 | ID string `json:"Id"` 79 | *Config 80 | } 81 | -------------------------------------------------------------------------------- /hack/environment/master.cfg: -------------------------------------------------------------------------------- 1 | import os 2 | from buildbot.buildslave import BuildSlave 3 | from buildbot.schedulers.forcesched import ForceScheduler 4 | from buildbot.config import BuilderConfig 5 | from buildbot.process.factory import BuildFactory 6 | from buildbot.steps.shell import ShellCommand 7 | from buildbot.status import html 8 | from buildbot.status.web import authz, auth 9 | 10 | PORT_WEB = 8010 # Buildbot webserver port 11 | PORT_MASTER = 9989 # Port where buildbot master listen buildworkers 12 | TEST_USER = 'buildbot' # Credential to authenticate build triggers 13 | TEST_PWD = 'docker' # Credential to authenticate build triggers 14 | BUILDER_NAME = 'docker' 15 | BUILDPASSWORD = 'pass-docker' # Credential to authenticate buildworkers 16 | GOPATH = '/data/docker' 17 | DOCKER_PATH = '{0}/src/github.com/dotcloud/docker'.format(GOPATH) 18 | 19 | c = BuildmasterConfig = {} 20 | 21 | c['title'] = "Docker" 22 | c['titleURL'] = "waterfall" 23 | c['buildbotURL'] = "http://localhost:{0}/".format(PORT_WEB) 24 | c['db'] = {'db_url':"sqlite:///state.sqlite"} 25 | c['slaves'] = [BuildSlave('buildworker', BUILDPASSWORD)] 26 | c['slavePortnum'] = PORT_MASTER 27 | 28 | c['schedulers'] = [ForceScheduler(name='trigger',builderNames=[BUILDER_NAME])] 29 | 30 | # Docker test command 31 | test_cmd = "GOPATH={0} make -C {1} test".format(GOPATH,DOCKER_PATH) 32 | 33 | # Builder 34 | factory = BuildFactory() 35 | factory.addStep(ShellCommand(description='Docker',logEnviron=False, 36 | usePTY=True,command=test_cmd)) 37 | c['builders'] = [BuilderConfig(name=BUILDER_NAME,slavenames=['buildworker'], 38 | factory=factory)] 39 | 40 | # Status 41 | authz_cfg=authz.Authz(auth=auth.BasicAuth([(TEST_USER,TEST_PWD)]), 42 | forceBuild='auth') 43 | c['status'] = [html.WebStatus(http_port=PORT_WEB, authz=authz_cfg)] 44 | -------------------------------------------------------------------------------- /docs/theme/docker/static/js/jquery.ba-urlinternal.min.js: -------------------------------------------------------------------------------- 1 | /* 2 | * urlInternal - v1.0 - 10/7/2009 3 | * http://benalman.com/projects/jquery-urlinternal-plugin/ 4 | * 5 | * Copyright (c) 2009 "Cowboy" Ben Alman 6 | * Dual licensed under the MIT and GPL licenses. 7 | * http://benalman.com/about/license/ 8 | */ 9 | (function($){var g,i=!0,r=!1,m=window.location,h=Array.prototype.slice,b=m.href.match(/^((https?:\/\/.*?\/)?[^#]*)#?.*$/),u=b[1]+"#",t=b[2],e,l,f,q,c,j,x="elemUrlAttr",k="href",y="src",p="urlInternal",d="urlExternal",n="urlFragment",a,s={};function w(A){var z=h.call(arguments,1);return function(){return A.apply(this,z.concat(h.call(arguments)))}}$.isUrlInternal=q=function(z){if(!z||j(z)){return g}if(a.test(z)){return i}if(/^(?:https?:)?\/\//i.test(z)){return r}if(/^[a-z\d.-]+:/i.test(z)){return g}return i};$.isUrlExternal=c=function(z){var A=q(z);return typeof A==="boolean"?!A:A};$.isUrlFragment=j=function(z){var A=(z||"").match(/^([^#]?)([^#]*#).*$/);return !!A&&(A[2]==="#"||z.indexOf(u)===0||(A[1]==="/"?t+A[2]===u:!/^https?:\/\//i.test(z)&&$('')[0].href.indexOf(u)===0))};function v(A,z){return this.filter(":"+A+(z?"("+z+")":""))}$.fn[p]=w(v,p);$.fn[d]=w(v,d);$.fn[n]=w(v,n);function o(D,C,B,A){var z=A[3]||e()[(C.nodeName||"").toLowerCase()]||"";return z?!!D(C.getAttribute(z)):r}$.expr[":"][p]=w(o,q);$.expr[":"][d]=w(o,c);$.expr[":"][n]=w(o,j);$[x]||($[x]=function(z){return $.extend(s,z)})({a:k,base:k,iframe:y,img:y,input:y,form:"action",link:k,script:y});e=$[x];$.urlInternalHost=l=function(B){B=B?"(?:(?:"+Array.prototype.join.call(arguments,"|")+")\\.)?":"";var A=new RegExp("^"+B+"(.*)","i"),z="^(?:"+m.protocol+")?//"+m.hostname.replace(A,B+"$1").replace(/\\?\./g,"\\.")+(m.port?":"+m.port:"")+"/";return f(z)};$.urlInternalRegExp=f=function(z){if(z){a=typeof z==="string"?new RegExp(z,"i"):z}return a};l("www")})(jQuery); -------------------------------------------------------------------------------- /hack/dockerbuilder/Dockerfile: -------------------------------------------------------------------------------- 1 | # DESCRIPTION Build a container capable of producing official binary and 2 | # PPA packages and uploading them to S3 and Launchpad 3 | # VERSION 1.2 4 | # DOCKER_VERSION 0.4 5 | # AUTHOR Solomon Hykes 6 | # Daniel Mizyrycki 7 | # BUILD_CMD docker build -t dockerbuilder . 8 | # RUN_CMD docker run -e AWS_ID="$AWS_ID" -e AWS_KEY="$AWS_KEY" -e GPG_KEY="$GPG_KEY" dockerbuilder 9 | # 10 | # 11 | from ubuntu:12.04 12 | maintainer Solomon Hykes 13 | # Workaround the upstart issue 14 | run dpkg-divert --local --rename --add /sbin/initctl 15 | run ln -s /bin/true /sbin/initctl 16 | # Enable universe and gophers PPA 17 | run DEBIAN_FRONTEND=noninteractive apt-get install -y -q python-software-properties 18 | run add-apt-repository "deb http://archive.ubuntu.com/ubuntu $(lsb_release -sc) universe" 19 | run add-apt-repository -y ppa:dotcloud/docker-golang/ubuntu 20 | run apt-get update 21 | # Packages required to checkout, build and upload docker 22 | run DEBIAN_FRONTEND=noninteractive apt-get install -y -q s3cmd curl 23 | run curl -s -o /go.tar.gz https://go.googlecode.com/files/go1.1.1.linux-amd64.tar.gz 24 | run tar -C /usr/local -xzf /go.tar.gz 25 | run echo "export PATH=/usr/local/go/bin:$PATH" > /.bashrc 26 | run echo "export PATH=/usr/local/go/bin:$PATH" > /.bash_profile 27 | run DEBIAN_FRONTEND=noninteractive apt-get install -y -q git build-essential 28 | # Packages required to build an ubuntu package 29 | run DEBIAN_FRONTEND=noninteractive apt-get install -y -q golang-stable debhelper autotools-dev devscripts 30 | # Copy dockerbuilder files into the container 31 | add . /src 32 | run cp /src/dockerbuilder /usr/local/bin/ && chmod +x /usr/local/bin/dockerbuilder 33 | cmd ["dockerbuilder"] 34 | -------------------------------------------------------------------------------- /docs/sources/examples/couchdb_data_volumes.rst: -------------------------------------------------------------------------------- 1 | :title: Sharing data between 2 couchdb databases 2 | :description: Sharing data between 2 couchdb databases 3 | :keywords: docker, example, package installation, networking, couchdb, data volumes 4 | 5 | .. _running_couchdb_service: 6 | 7 | CouchDB Service 8 | =============== 9 | 10 | .. include:: example_header.inc 11 | 12 | Here's an example of using data volumes to share the same data between 2 couchdb containers. 13 | This could be used for hot upgrades, testing different versions of couchdb on the same data, etc. 14 | 15 | Create first database 16 | --------------------- 17 | 18 | Note that we're marking /var/lib/couchdb as a data volume. 19 | 20 | .. code-block:: bash 21 | 22 | COUCH1=$(docker run -d -v /var/lib/couchdb shykes/couchdb:2013-05-03) 23 | 24 | Add data to the first database 25 | ------------------------------ 26 | 27 | We're assuming your docker host is reachable at `localhost`. If not, replace `localhost` with the public IP of your docker host. 28 | 29 | .. code-block:: bash 30 | 31 | HOST=localhost 32 | URL="http://$HOST:$(docker port $COUCH1 5984)/_utils/" 33 | echo "Navigate to $URL in your browser, and use the couch interface to add data" 34 | 35 | Create second database 36 | ---------------------- 37 | 38 | This time, we're requesting shared access to $COUCH1's volumes. 39 | 40 | .. code-block:: bash 41 | 42 | COUCH2=$(docker run -d -volumes-from $COUCH1) shykes/couchdb:2013-05-03) 43 | 44 | Browse data on the second database 45 | ---------------------------------- 46 | 47 | .. code-block:: bash 48 | 49 | HOST=localhost 50 | URL="http://$HOST:$(docker port $COUCH2 5984)/_utils/" 51 | echo "Navigate to $URL in your browser. You should see the same data as in the first database!" 52 | 53 | Congratulations, you are running 2 Couchdb containers, completely isolated from each other *except* for their data. 54 | -------------------------------------------------------------------------------- /contrib/install.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # This script is meant for quick & easy install via 'curl URL-OF-SCRIPT | sh' 3 | # Original version by Jeff Lindsay 4 | # Revamped by Jerome Petazzoni 5 | # 6 | # This script canonical location is http://get.docker.io/; to update it, run: 7 | # s3cmd put -m text/x-shellscript -P install.sh s3://get.docker.io/index 8 | 9 | echo "Ensuring basic dependencies are installed..." 10 | apt-get -qq update 11 | apt-get -qq install lxc wget 12 | 13 | echo "Looking in /proc/filesystems to see if we have AUFS support..." 14 | if grep -q aufs /proc/filesystems 15 | then 16 | echo "Found." 17 | else 18 | echo "Ahem, it looks like the current kernel does not support AUFS." 19 | echo "Let's see if we can load the AUFS module with modprobe..." 20 | if modprobe aufs 21 | then 22 | echo "Module loaded." 23 | else 24 | echo "Ahem, things didn't turn out as expected." 25 | KPKG=linux-image-extra-$(uname -r) 26 | echo "Trying to install $KPKG..." 27 | if apt-get -qq install $KPKG 28 | then 29 | echo "Installed." 30 | else 31 | echo "Oops, we couldn't install the -extra kernel." 32 | echo "Are you sure you are running a supported version of Ubuntu?" 33 | echo "Proceeding anyway, but Docker will probably NOT WORK!" 34 | fi 35 | fi 36 | fi 37 | 38 | echo "Downloading docker binary and uncompressing into /usr/local/bin..." 39 | curl -s http://get.docker.io/builds/$(uname -s)/$(uname -m)/docker-latest.tgz | 40 | tar -C /usr/local/bin --strip-components=1 -zxf- \ 41 | docker-latest/docker 42 | 43 | if [ -f /etc/init/dockerd.conf ] 44 | then 45 | echo "Upstart script already exists." 46 | else 47 | echo "Creating /etc/init/dockerd.conf..." 48 | echo "exec env LANG=\"en_US.UTF-8\" /usr/local/bin/docker -d" > /etc/init/dockerd.conf 49 | fi 50 | 51 | echo "Starting dockerd..." 52 | start dockerd > /dev/null 53 | 54 | echo "Done." 55 | echo 56 | -------------------------------------------------------------------------------- /packaging/debian/lxc-docker.init: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | ### BEGIN INIT INFO 4 | # Provides: lxc-docker 5 | # Required-Start: $syslog $remote_fs 6 | # Required-Stop: $syslog $remote_fs 7 | # Default-Start: 2 3 4 5 8 | # Default-Stop: 0 1 6 9 | # Short-Description: Linux container runtime 10 | # Description: Linux container runtime 11 | ### END INIT INFO 12 | 13 | DOCKER=/usr/bin/lxc-docker 14 | 15 | # Check lxc-docker is present 16 | [ -x $DOCKER ] || (log_failure_msg "lxc-docker not present"; exit 1) 17 | 18 | PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin 19 | 20 | # Get lsb functions 21 | . /lib/lsb/init-functions 22 | 23 | check_root_id () 24 | { 25 | if [ "$(id -u)" != "0" ]; then 26 | log_failure_msg "LXC Docker must be run as root"; exit 1 27 | fi 28 | } 29 | 30 | case "$1" in 31 | start) 32 | check_root_id || exit 1 33 | log_begin_msg "Starting LXC Docker" 34 | mount | grep cgroup >/dev/null || mount -t cgroup none /sys/fs/cgroup 35 | start-stop-daemon --start --background --exec "$DOCKER" -- -d 36 | log_end_msg $? 37 | ;; 38 | 39 | stop) 40 | check_root_id || exit 1 41 | log_begin_msg "Stopping LXC Docker" 42 | docker_pid=`pgrep -f "$DOCKER -d"` 43 | [ -n "$docker_pid" ] && kill $docker_pid 44 | log_end_msg $? 45 | ;; 46 | 47 | restart) 48 | check_root_id || exit 1 49 | docker_pid=`pgrep -f "$DOCKER -d"` 50 | [ -n "$docker_pid" ] && /etc/init.d/lxc-docker stop 51 | /etc/init.d/lxc-docker start 52 | ;; 53 | 54 | force-reload) 55 | check_root_id || exit 1 56 | /etc/init.d/lxc-docker restart 57 | ;; 58 | 59 | status) 60 | docker_pid=`pgrep -f "$DOCKER -d"` 61 | if [ -z "$docker_pid" ] ; then 62 | echo "lxc-docker not running" 63 | else 64 | echo "lxc-docker running (pid $docker_pid)" 65 | fi 66 | ;; 67 | 68 | *) 69 | echo "Usage: /etc/init.d/lxc-docker {start|stop|restart|status}" 70 | exit 1 71 | ;; 72 | esac 73 | 74 | exit 0 75 | -------------------------------------------------------------------------------- /docs/sources/commandline/command/build.rst: -------------------------------------------------------------------------------- 1 | :title: Build Command 2 | :description: Build a new image from the Dockerfile passed via stdin 3 | :keywords: build, docker, container, documentation 4 | 5 | ================================================ 6 | ``build`` -- Build a container from a Dockerfile 7 | ================================================ 8 | 9 | :: 10 | 11 | Usage: docker build [OPTIONS] PATH | URL | - 12 | Build a new container image from the source code at PATH 13 | -t="": Tag to be applied to the resulting image in case of success. 14 | When a single Dockerfile is given as URL, then no context is set. When a git repository is set as URL, the repository is used as context 15 | 16 | 17 | Examples 18 | -------- 19 | 20 | .. code-block:: bash 21 | 22 | docker build . 23 | 24 | | This will read the Dockerfile from the current directory. It will also send any other files and directories found in the current directory to the docker daemon. 25 | | The contents of this directory would be used by ADD commands found within the Dockerfile. 26 | | This will send a lot of data to the docker daemon if the current directory contains a lot of data. 27 | | If the absolute path is provided instead of '.', only the files and directories required by the ADD commands from the Dockerfile will be added to the context and transferred to the docker daemon. 28 | | 29 | 30 | .. code-block:: bash 31 | 32 | docker build - < Dockerfile 33 | 34 | | This will read a Dockerfile from Stdin without context. Due to the lack of a context, no contents of any local directory will be sent to the docker daemon. 35 | | ADD doesn't work when running in this mode due to the absence of the context, thus having no source files to copy to the container. 36 | 37 | 38 | .. code-block:: bash 39 | 40 | docker build github.com/creack/docker-firefox 41 | 42 | | This will clone the github repository and use it as context. The Dockerfile at the root of the repository is used as Dockerfile. 43 | | Note that you can specify an arbitrary git repository by using the 'git://' schema. 44 | -------------------------------------------------------------------------------- /docs/sources/faq.rst: -------------------------------------------------------------------------------- 1 | :title: FAQ 2 | :description: Most frequently asked questions. 3 | :keywords: faq, questions, documentation, docker 4 | 5 | FAQ 6 | === 7 | 8 | 9 | Most frequently asked questions. 10 | -------------------------------- 11 | 12 | 1. **How much does Docker cost?** 13 | 14 | Docker is 100% free, it is open source, so you can use it without paying. 15 | 16 | 2. **What open source license are you using?** 17 | 18 | We are using the Apache License Version 2.0, see it here: https://github.com/dotcloud/docker/blob/master/LICENSE 19 | 20 | 3. **Does Docker run on Mac OS X or Windows?** 21 | 22 | Not at this time, Docker currently only runs on Linux, but you can use VirtualBox to run Docker in a 23 | virtual machine on your box, and get the best of both worlds. Check out the :ref:`install_using_vagrant` and :ref:`windows` installation guides. 24 | 25 | 4. **How do containers compare to virtual machines?** 26 | 27 | They are complementary. VMs are best used to allocate chunks of hardware resources. Containers operate at the process level, which makes them very lightweight and perfect as a unit of software delivery. 28 | 29 | 5. **Can I help by adding some questions and answers?** 30 | 31 | Definitely! You can fork `the repo`_ and edit the documentation sources. 32 | 33 | 34 | 42. **Where can I find more answers?** 35 | 36 | You can find more answers on: 37 | 38 | * `Docker club mailinglist`_ 39 | * `IRC, docker on freenode`_ 40 | * `Github`_ 41 | * `Ask questions on Stackoverflow`_ 42 | * `Join the conversation on Twitter`_ 43 | 44 | 45 | .. _Docker club mailinglist: https://groups.google.com/d/forum/docker-club 46 | .. _the repo: http://www.github.com/dotcloud/docker 47 | .. _IRC, docker on freenode: irc://chat.freenode.net#docker 48 | .. _Github: http://www.github.com/dotcloud/docker 49 | .. _Ask questions on Stackoverflow: http://stackoverflow.com/search?q=docker 50 | .. _Join the conversation on Twitter: http://twitter.com/getdocker 51 | 52 | 53 | Looking for something else to read? Checkout the :ref:`hello_world` example. 54 | -------------------------------------------------------------------------------- /docs/sources/installation/vagrant.rst: -------------------------------------------------------------------------------- 1 | :title: Using Vagrant (Mac, Linux) 2 | :description: This guide will setup a new virtualbox virtual machine with docker installed on your computer. 3 | :keywords: Docker, Docker documentation, virtualbox, vagrant, git, ssh, putty, cygwin 4 | 5 | .. _install_using_vagrant: 6 | 7 | Using Vagrant (Mac, Linux) 8 | ========================== 9 | 10 | This guide will setup a new virtualbox virtual machine with docker installed on your computer. This works on most operating 11 | systems, including MacOX, Windows, Linux, FreeBSD and others. If you can install these and have at least 400Mb RAM 12 | to spare you should be good. 13 | 14 | 15 | Install Vagrant and Virtualbox 16 | ------------------------------ 17 | 18 | 1. Install virtualbox from https://www.virtualbox.org/ (or use your package manager) 19 | 2. Install vagrant from http://www.vagrantup.com/ (or use your package manager) 20 | 3. Install git if you had not installed it before, check if it is installed by running 21 | ``git`` in a terminal window 22 | 23 | 24 | Spin it up 25 | ---------- 26 | 27 | 1. Fetch the docker sources (this includes the Vagrantfile for machine setup). 28 | 29 | .. code-block:: bash 30 | 31 | git clone https://github.com/dotcloud/docker.git 32 | 33 | 2. Run vagrant from the sources directory 34 | 35 | .. code-block:: bash 36 | 37 | vagrant up 38 | 39 | Vagrant will: 40 | 41 | * Download the 'official' Precise64 base ubuntu virtual machine image from vagrantup.com 42 | * Boot this image in virtualbox 43 | * Add the `Docker PPA sources `_ to /etc/apt/sources.lst 44 | * Update your sources 45 | * Install lxc-docker 46 | 47 | You now have a Ubuntu Virtual Machine running with docker pre-installed. 48 | 49 | Connect 50 | ------- 51 | 52 | To access the VM and use Docker, Run ``vagrant ssh`` from the same directory as where you ran 53 | ``vagrant up``. Vagrant will connect you to the correct VM. 54 | 55 | .. code-block:: bash 56 | 57 | vagrant ssh 58 | 59 | Run 60 | ----- 61 | 62 | Now you are in the VM, run docker 63 | 64 | .. code-block:: bash 65 | 66 | docker 67 | 68 | 69 | Continue with the :ref:`hello_world` example. 70 | -------------------------------------------------------------------------------- /docs/sources/examples/running_redis_service.rst: -------------------------------------------------------------------------------- 1 | :title: Running a Redis service 2 | :description: Installing and running an redis service 3 | :keywords: docker, example, package installation, networking, redis 4 | 5 | .. _running_redis_service: 6 | 7 | Redis Service 8 | ============= 9 | 10 | .. include:: example_header.inc 11 | 12 | Very simple, no frills, redis service. 13 | 14 | Open a docker container 15 | ----------------------- 16 | 17 | .. code-block:: bash 18 | 19 | docker run -i -t base /bin/bash 20 | 21 | Building your image 22 | ------------------- 23 | 24 | Update your docker container, install the redis server. Once installed, exit out of docker. 25 | 26 | .. code-block:: bash 27 | 28 | apt-get update 29 | apt-get install redis-server 30 | exit 31 | 32 | Snapshot the installation 33 | ------------------------- 34 | 35 | .. code-block:: bash 36 | 37 | docker ps -a # grab the container id (this will be the first one in the list) 38 | docker commit /redis 39 | 40 | Run the service 41 | --------------- 42 | 43 | Running the service with `-d` runs the container in detached mode, leaving the 44 | container running in the background. Use your snapshot. 45 | 46 | .. code-block:: bash 47 | 48 | docker run -d -p 6379 /redis /usr/bin/redis-server 49 | 50 | Test 1 51 | ++++++ 52 | 53 | Connect to the container with the redis-cli. 54 | 55 | .. code-block:: bash 56 | 57 | docker ps # grab the new container id 58 | docker inspect # grab the ipaddress of the container 59 | redis-cli -h -p 6379 60 | redis 10.0.3.32:6379> set docker awesome 61 | OK 62 | redis 10.0.3.32:6379> get docker 63 | "awesome" 64 | redis 10.0.3.32:6379> exit 65 | 66 | Test 2 67 | ++++++ 68 | 69 | Connect to the host os with the redis-cli. 70 | 71 | .. code-block:: bash 72 | 73 | docker ps # grab the new container id 74 | docker port 6379 # grab the external port 75 | ip addr show # grab the host ip address 76 | redis-cli -h -p 77 | redis 192.168.0.1:49153> set docker awesome 78 | OK 79 | redis 192.168.0.1:49153> get docker 80 | "awesome" 81 | redis 192.168.0.1:49153> exit 82 | -------------------------------------------------------------------------------- /utils.go: -------------------------------------------------------------------------------- 1 | package docker 2 | 3 | // Compare two Config struct. Do not compare the "Image" nor "Hostname" fields 4 | // If OpenStdin is set, then it differs 5 | func CompareConfig(a, b *Config) bool { 6 | if a == nil || b == nil || 7 | a.OpenStdin || b.OpenStdin { 8 | return false 9 | } 10 | if a.AttachStdout != b.AttachStdout || 11 | a.AttachStderr != b.AttachStderr || 12 | a.User != b.User || 13 | a.Memory != b.Memory || 14 | a.MemorySwap != b.MemorySwap || 15 | a.CpuShares != b.CpuShares || 16 | a.OpenStdin != b.OpenStdin || 17 | a.Tty != b.Tty { 18 | return false 19 | } 20 | if len(a.Cmd) != len(b.Cmd) || 21 | len(a.Dns) != len(b.Dns) || 22 | len(a.Env) != len(b.Env) || 23 | len(a.PortSpecs) != len(b.PortSpecs) { 24 | return false 25 | } 26 | 27 | for i := 0; i < len(a.Cmd); i++ { 28 | if a.Cmd[i] != b.Cmd[i] { 29 | return false 30 | } 31 | } 32 | for i := 0; i < len(a.Dns); i++ { 33 | if a.Dns[i] != b.Dns[i] { 34 | return false 35 | } 36 | } 37 | for i := 0; i < len(a.Env); i++ { 38 | if a.Env[i] != b.Env[i] { 39 | return false 40 | } 41 | } 42 | for i := 0; i < len(a.PortSpecs); i++ { 43 | if a.PortSpecs[i] != b.PortSpecs[i] { 44 | return false 45 | } 46 | } 47 | 48 | return true 49 | } 50 | 51 | func MergeConfig(userConf, imageConf *Config) { 52 | if userConf.Hostname == "" { 53 | userConf.Hostname = imageConf.Hostname 54 | } 55 | if userConf.User == "" { 56 | userConf.User = imageConf.User 57 | } 58 | if userConf.Memory == 0 { 59 | userConf.Memory = imageConf.Memory 60 | } 61 | if userConf.MemorySwap == 0 { 62 | userConf.MemorySwap = imageConf.MemorySwap 63 | } 64 | if userConf.CpuShares == 0 { 65 | userConf.CpuShares = imageConf.CpuShares 66 | } 67 | if userConf.PortSpecs == nil || len(userConf.PortSpecs) == 0 { 68 | userConf.PortSpecs = imageConf.PortSpecs 69 | } 70 | if !userConf.Tty { 71 | userConf.Tty = imageConf.Tty 72 | } 73 | if !userConf.OpenStdin { 74 | userConf.OpenStdin = imageConf.OpenStdin 75 | } 76 | if !userConf.StdinOnce { 77 | userConf.StdinOnce = imageConf.StdinOnce 78 | } 79 | if userConf.Env == nil || len(userConf.Env) == 0 { 80 | userConf.Env = imageConf.Env 81 | } 82 | if userConf.Cmd == nil || len(userConf.Cmd) == 0 { 83 | userConf.Cmd = imageConf.Cmd 84 | } 85 | if userConf.Dns == nil || len(userConf.Dns) == 0 { 86 | userConf.Dns = imageConf.Dns 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /auth/auth_test.go: -------------------------------------------------------------------------------- 1 | package auth 2 | 3 | import ( 4 | "crypto/rand" 5 | "encoding/hex" 6 | "os" 7 | "strings" 8 | "testing" 9 | ) 10 | 11 | func TestEncodeAuth(t *testing.T) { 12 | newAuthConfig := &AuthConfig{Username: "ken", Password: "test", Email: "test@example.com"} 13 | authStr := encodeAuth(newAuthConfig) 14 | decAuthConfig, err := decodeAuth(authStr) 15 | if err != nil { 16 | t.Fatal(err) 17 | } 18 | if newAuthConfig.Username != decAuthConfig.Username { 19 | t.Fatal("Encode Username doesn't match decoded Username") 20 | } 21 | if newAuthConfig.Password != decAuthConfig.Password { 22 | t.Fatal("Encode Password doesn't match decoded Password") 23 | } 24 | if authStr != "a2VuOnRlc3Q=" { 25 | t.Fatal("AuthString encoding isn't correct.") 26 | } 27 | } 28 | 29 | func TestLogin(t *testing.T) { 30 | os.Setenv("DOCKER_INDEX_URL", "https://indexstaging-docker.dotcloud.com") 31 | defer os.Setenv("DOCKER_INDEX_URL", "") 32 | authConfig := NewAuthConfig("unittester", "surlautrerivejetattendrai", "noise+unittester@dotcloud.com", "/tmp") 33 | status, err := Login(authConfig, false) 34 | if err != nil { 35 | t.Fatal(err) 36 | } 37 | if status != "Login Succeeded" { 38 | t.Fatalf("Expected status \"Login Succeeded\", found \"%s\" instead", status) 39 | } 40 | } 41 | 42 | func TestCreateAccount(t *testing.T) { 43 | os.Setenv("DOCKER_INDEX_URL", "https://indexstaging-docker.dotcloud.com") 44 | defer os.Setenv("DOCKER_INDEX_URL", "") 45 | tokenBuffer := make([]byte, 16) 46 | _, err := rand.Read(tokenBuffer) 47 | if err != nil { 48 | t.Fatal(err) 49 | } 50 | token := hex.EncodeToString(tokenBuffer)[:12] 51 | username := "ut" + token 52 | authConfig := NewAuthConfig(username, "test42", "docker-ut+"+token+"@example.com", "/tmp") 53 | status, err := Login(authConfig, false) 54 | if err != nil { 55 | t.Fatal(err) 56 | } 57 | expectedStatus := "Account created. Please use the confirmation link we sent" + 58 | " to your e-mail to activate it." 59 | if status != expectedStatus { 60 | t.Fatalf("Expected status: \"%s\", found \"%s\" instead.", expectedStatus, status) 61 | } 62 | 63 | status, err = Login(authConfig, false) 64 | if err == nil { 65 | t.Fatalf("Expected error but found nil instead") 66 | } 67 | 68 | expectedError := "Login: Account is not Active" 69 | 70 | if !strings.Contains(err.Error(), expectedError) { 71 | t.Fatalf("Expected message \"%s\" but found \"%s\" instead", expectedError, err.Error()) 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /testing/buildbot/master.cfg: -------------------------------------------------------------------------------- 1 | import os 2 | from buildbot.buildslave import BuildSlave 3 | from buildbot.schedulers.forcesched import ForceScheduler 4 | from buildbot.schedulers.basic import SingleBranchScheduler 5 | from buildbot.changes import filter 6 | from buildbot.config import BuilderConfig 7 | from buildbot.process.factory import BuildFactory 8 | from buildbot.steps.shell import ShellCommand 9 | from buildbot.status import html 10 | from buildbot.status.web import authz, auth 11 | 12 | PORT_WEB = 80 # Buildbot webserver port 13 | PORT_GITHUB = 8011 # Buildbot github hook port 14 | PORT_MASTER = 9989 # Port where buildbot master listen buildworkers 15 | TEST_USER = 'buildbot' # Credential to authenticate build triggers 16 | TEST_PWD = 'docker' # Credential to authenticate build triggers 17 | BUILDER_NAME = 'docker' 18 | BUILDPASSWORD = 'pass-docker' # Credential to authenticate buildworkers 19 | GITHUB_DOCKER = "github.com/dotcloud/docker" 20 | DOCKER_PATH = "/data/docker" 21 | BUILDER_PATH = "/data/buildbot/slave/{0}/build".format(BUILDER_NAME) 22 | DOCKER_BUILD_PATH = BUILDER_PATH + '/src/github.com/dotcloud/docker' 23 | 24 | 25 | c = BuildmasterConfig = {} 26 | 27 | c['title'] = "Docker" 28 | c['titleURL'] = "waterfall" 29 | c['buildbotURL'] = "http://0.0.0.0:{0}/".format(PORT_WEB) 30 | c['db'] = {'db_url':"sqlite:///state.sqlite"} 31 | c['slaves'] = [BuildSlave('buildworker', BUILDPASSWORD)] 32 | c['slavePortnum'] = PORT_MASTER 33 | 34 | c['schedulers'] = [ForceScheduler(name='trigger',builderNames=[BUILDER_NAME])] 35 | c['schedulers'].append(SingleBranchScheduler(name="all", 36 | change_filter=filter.ChangeFilter(branch='master'),treeStableTimer=None, 37 | builderNames=[BUILDER_NAME])) 38 | 39 | # Docker test command 40 | test_cmd = ("cd /tmp; rm -rf {0}; export GOPATH={0}; go get -d {1}; cd {2}; " 41 | "go test").format(BUILDER_PATH,GITHUB_DOCKER,DOCKER_BUILD_PATH) 42 | 43 | # Builder 44 | factory = BuildFactory() 45 | factory.addStep(ShellCommand(description='Docker',logEnviron=False, 46 | usePTY=True,command=test_cmd)) 47 | c['builders'] = [BuilderConfig(name=BUILDER_NAME,slavenames=['buildworker'], 48 | factory=factory)] 49 | 50 | # Status 51 | authz_cfg=authz.Authz(auth=auth.BasicAuth([(TEST_USER,TEST_PWD)]), 52 | forceBuild='auth') 53 | c['status'] = [html.WebStatus(http_port=PORT_WEB, authz=authz_cfg)] 54 | c['status'].append(html.WebStatus(http_port=PORT_GITHUB,allowForce=True, 55 | change_hook_dialects={ 'github' : True })) 56 | -------------------------------------------------------------------------------- /testing/Vagrantfile: -------------------------------------------------------------------------------- 1 | # -*- mode: ruby -*- 2 | # vi: set ft=ruby : 3 | 4 | BOX_NAME = "docker-ci" 5 | BOX_URI = "http://files.vagrantup.com/precise64.box" 6 | AWS_AMI = "ami-d0f89fb9" 7 | DOCKER_PATH = "/data/docker" 8 | CFG_PATH = "#{DOCKER_PATH}/testing/buildbot" 9 | BUILDBOT_IP = "192.168.33.41" 10 | on_vbox = File.file?("#{File.dirname(__FILE__)}/.vagrant/machines/default/virtualbox/id") | \ 11 | Dir.glob("#{File.dirname(__FILE__)}/.vagrant/machines/default/*/id").empty? & \ 12 | (on_vbox=true; ARGV.each do |arg| on_vbox &&= !arg.downcase.start_with?("--provider") end; on_vbox) 13 | USER = on_vbox ? "vagrant": "ubuntu" 14 | 15 | Vagrant::Config.run do |config| 16 | # Setup virtual machine box. This VM configuration code is always executed. 17 | config.vm.box = BOX_NAME 18 | config.vm.box_url = BOX_URI 19 | config.vm.share_folder "v-data", DOCKER_PATH, "#{File.dirname(__FILE__)}/.." 20 | config.vm.network :hostonly, BUILDBOT_IP 21 | 22 | # Deploy buildbot and its dependencies if it was not done 23 | if Dir.glob("#{File.dirname(__FILE__)}/.vagrant/machines/default/*/id").empty? 24 | pkg_cmd = "apt-get update -qq; apt-get install -q -y linux-image-3.8.0-19-generic; " 25 | # Deploy buildbot CI 26 | pkg_cmd << "apt-get install -q -y python-dev python-pip supervisor; " \ 27 | "pip install -r #{CFG_PATH}/requirements.txt; " \ 28 | "chown #{USER}.#{USER} /data; cd /data; " \ 29 | "#{CFG_PATH}/setup.sh #{USER} #{CFG_PATH}; " 30 | # Install docker dependencies 31 | pkg_cmd << "apt-get install -q -y python-software-properties; " \ 32 | "add-apt-repository -y ppa:gophers/go/ubuntu; apt-get update -qq; " \ 33 | "DEBIAN_FRONTEND=noninteractive apt-get install -q -y lxc git golang-stable aufs-tools make; " 34 | # Activate new kernel 35 | pkg_cmd << "shutdown -r +1; " 36 | config.vm.provision :shell, :inline => pkg_cmd 37 | end 38 | end 39 | 40 | # Providers were added on Vagrant >= 1.1.0 41 | Vagrant::VERSION >= "1.1.0" and Vagrant.configure("2") do |config| 42 | config.vm.provider :aws do |aws, override| 43 | aws.access_key_id = ENV["AWS_ACCESS_KEY_ID"] 44 | aws.secret_access_key = ENV["AWS_SECRET_ACCESS_KEY"] 45 | aws.keypair_name = ENV["AWS_KEYPAIR_NAME"] 46 | override.ssh.private_key_path = ENV["AWS_SSH_PRIVKEY"] 47 | override.ssh.username = USER 48 | aws.ami = AWS_AMI 49 | aws.region = "us-east-1" 50 | aws.instance_type = "m1.small" 51 | aws.security_groups = "gateway" 52 | end 53 | 54 | config.vm.provider :virtualbox do |vb| 55 | end 56 | end 57 | -------------------------------------------------------------------------------- /packaging/debian/Makefile: -------------------------------------------------------------------------------- 1 | # Debian package Makefile 2 | # 3 | # Dependencies: git debhelper build-essential autotools-dev devscripts golang 4 | # Notes: 5 | # Use 'make debian' to create the debian package 6 | # To create a specific version, use 'VERSION_TAG=v0.2.0 make debian' 7 | # GPG_KEY environment variable needs to contain a GPG private key for package 8 | # to be signed and uploaded to debian. 9 | # If GPG_KEY is not defined, make debian will create docker package and exit 10 | # with status code 2 11 | 12 | PKG_NAME=lxc-docker 13 | ROOT_PATH=$(shell git rev-parse --show-toplevel) 14 | GITHUB_PATH=github.com/dotcloud/docker 15 | BUILD_SRC=build_src 16 | VERSION_TAG?=v$(shell sed -E 's/.+\((.+)-.+\).+/\1/;q' changelog) 17 | VERSION=$(shell echo ${VERSION_TAG} | cut -c2-) 18 | DOCKER_VERSION=${PKG_NAME}_${VERSION} 19 | 20 | all: 21 | # Compile docker. Used by debian dpkg-buildpackage. 22 | cd src/${GITHUB_PATH}/docker; GOPATH=${CURDIR} go build 23 | 24 | install: 25 | # Used by debian dpkg-buildpackage 26 | mkdir -p $(DESTDIR)/usr/bin 27 | mkdir -p $(DESTDIR)/usr/share/man/man1 28 | mkdir -p $(DESTDIR)/usr/share/doc/lxc-docker 29 | install -m 0755 src/${GITHUB_PATH}/docker/docker $(DESTDIR)/usr/bin/lxc-docker 30 | cp debian/lxc-docker.1 $(DESTDIR)/usr/share/man/man1 31 | cp debian/CHANGELOG.md $(DESTDIR)/usr/share/doc/lxc-docker/changelog 32 | 33 | debian: 34 | # Prepare docker source from revision ${VERSION_TAG} 35 | rm -rf ${BUILD_SRC} ${PKG_NAME}_[0-9]* 36 | git clone file://$(ROOT_PATH) ${BUILD_SRC}/src/${GITHUB_PATH} --branch ${VERSION_TAG} --depth 1 37 | GOPATH=${CURDIR}/${BUILD_SRC} go get -d ${GITHUB_PATH} 38 | # Add debianization 39 | mkdir ${BUILD_SRC}/debian 40 | cp Makefile ${BUILD_SRC} 41 | cp -r `ls | grep -v ${BUILD_SRC}` ${BUILD_SRC}/debian 42 | cp ${ROOT_PATH}/README.md ${BUILD_SRC} 43 | cp ${ROOT_PATH}/CHANGELOG.md ${BUILD_SRC}/debian 44 | # Cleanup 45 | rm -rf `find . -name '.git*'` 46 | rm -f ${DOCKER_VERSION}* 47 | # Create docker debian files 48 | cd ${BUILD_SRC}; tar czf ../${DOCKER_VERSION}.orig.tar.gz . 49 | cd ${BUILD_SRC}; dpkg-buildpackage -us -uc 50 | rm -rf ${BUILD_SRC} 51 | # Sign package and upload it to PPA if GPG_KEY environment variable 52 | # holds a private GPG KEY 53 | if /usr/bin/test "$${GPG_KEY}" == ""; then exit 2; fi 54 | mkdir ${BUILD_SRC} 55 | # Import gpg signing key 56 | echo "$${GPG_KEY}" | gpg --allow-secret-key-import --import 57 | # Sign the package 58 | cd ${BUILD_SRC}; dpkg-source -x ${CURDIR}/${DOCKER_VERSION}-1.dsc 59 | cd ${BUILD_SRC}/${PKG_NAME}-${VERSION}; debuild -S -sa 60 | -------------------------------------------------------------------------------- /docs/sources/installation/archlinux.rst: -------------------------------------------------------------------------------- 1 | :title: Installation on Arch Linux 2 | :description: Docker installation on Arch Linux. 3 | :keywords: arch linux, virtualization, docker, documentation, installation 4 | 5 | .. _arch_linux: 6 | 7 | Arch Linux 8 | ========== 9 | 10 | Please note this is a community contributed installation path. The only 'official' installation is using the 11 | :ref:`ubuntu_linux` installation path. This version may sometimes be out of date. 12 | 13 | 14 | Installing on Arch Linux is not officially supported but can be handled via 15 | either of the following AUR packages: 16 | 17 | * `lxc-docker `_ 18 | * `lxc-docker-git `_ 19 | 20 | The lxc-docker package will install the latest tagged version of docker. 21 | The lxc-docker-git package will build from the current master branch. 22 | 23 | Dependencies 24 | ------------ 25 | 26 | Docker depends on several packages which are specified as dependencies in 27 | either AUR package. 28 | 29 | * aufs3 30 | * bridge-utils 31 | * go 32 | * iproute2 33 | * linux-aufs_friendly 34 | * lxc 35 | 36 | Installation 37 | ------------ 38 | 39 | The instructions here assume **yaourt** is installed. See 40 | `Arch User Repository `_ 41 | for information on building and installing packages from the AUR if you have not 42 | done so before. 43 | 44 | Keep in mind that if **linux-aufs_friendly** is not already installed that a 45 | new kernel will be compiled and this can take quite a while. 46 | 47 | :: 48 | 49 | yaourt -S lxc-docker-git 50 | 51 | 52 | Starting Docker 53 | --------------- 54 | 55 | Prior to starting docker modify your bootloader to use the 56 | **linux-aufs_friendly** kernel and reboot your system. 57 | 58 | There is a systemd service unit created for docker. To start the docker service: 59 | 60 | :: 61 | 62 | sudo systemctl start docker 63 | 64 | 65 | To start on system boot: 66 | 67 | :: 68 | 69 | sudo systemctl enable docker 70 | 71 | Network Configuration 72 | --------------------- 73 | 74 | IPv4 packet forwarding is disabled by default on Arch, so internet access from inside 75 | the container may not work. 76 | 77 | To enable the forwarding, run as root on the host system: 78 | 79 | :: 80 | 81 | sysctl net.ipv4.ip_forward=1 82 | 83 | And, to make it persistent across reboots, enable it on the host's **/etc/sysctl.conf**: 84 | 85 | :: 86 | 87 | net.ipv4.ip_forward=1 88 | -------------------------------------------------------------------------------- /sysinit.go: -------------------------------------------------------------------------------- 1 | package docker 2 | 3 | import ( 4 | "flag" 5 | "fmt" 6 | "log" 7 | "os" 8 | "os/exec" 9 | "os/user" 10 | "strconv" 11 | "strings" 12 | "syscall" 13 | ) 14 | 15 | // Setup networking 16 | func setupNetworking(gw string) { 17 | if gw == "" { 18 | return 19 | } 20 | if _, err := ip("route", "add", "default", "via", gw); err != nil { 21 | log.Fatalf("Unable to set up networking: %v", err) 22 | } 23 | } 24 | 25 | // Takes care of dropping privileges to the desired user 26 | func changeUser(u string) { 27 | if u == "" { 28 | return 29 | } 30 | userent, err := user.LookupId(u) 31 | if err != nil { 32 | userent, err = user.Lookup(u) 33 | } 34 | if err != nil { 35 | log.Fatalf("Unable to find user %v: %v", u, err) 36 | } 37 | 38 | uid, err := strconv.Atoi(userent.Uid) 39 | if err != nil { 40 | log.Fatalf("Invalid uid: %v", userent.Uid) 41 | } 42 | gid, err := strconv.Atoi(userent.Gid) 43 | if err != nil { 44 | log.Fatalf("Invalid gid: %v", userent.Gid) 45 | } 46 | 47 | if err := syscall.Setgid(gid); err != nil { 48 | log.Fatalf("setgid failed: %v", err) 49 | } 50 | if err := syscall.Setuid(uid); err != nil { 51 | log.Fatalf("setuid failed: %v", err) 52 | } 53 | } 54 | 55 | // Clear environment pollution introduced by lxc-start 56 | func cleanupEnv(env ListOpts) { 57 | os.Clearenv() 58 | for _, kv := range env { 59 | parts := strings.SplitN(kv, "=", 2) 60 | if len(parts) == 1 { 61 | parts = append(parts, "") 62 | } 63 | if parts[0] == "container" { 64 | continue 65 | } 66 | os.Setenv(parts[0], parts[1]) 67 | } 68 | } 69 | 70 | func executeProgram(name string, args []string) { 71 | path, err := exec.LookPath(name) 72 | if err != nil { 73 | log.Printf("Unable to locate %v", name) 74 | os.Exit(127) 75 | } 76 | 77 | if err := syscall.Exec(path, args, os.Environ()); err != nil { 78 | panic(err) 79 | } 80 | } 81 | 82 | // Sys Init code 83 | // This code is run INSIDE the container and is responsible for setting 84 | // up the environment before running the actual process 85 | func SysInit() { 86 | if len(os.Args) <= 1 { 87 | fmt.Println("You should not invoke docker-init manually") 88 | os.Exit(1) 89 | } 90 | var u = flag.String("u", "", "username or uid") 91 | var gw = flag.String("g", "", "gateway address") 92 | 93 | var flEnv ListOpts 94 | flag.Var(&flEnv, "e", "Set environment variables") 95 | 96 | flag.Parse() 97 | 98 | cleanupEnv(flEnv) 99 | setupNetworking(*gw) 100 | changeUser(*u) 101 | executeProgram(flag.Arg(0), flag.Args()) 102 | } 103 | -------------------------------------------------------------------------------- /docs/README.md: -------------------------------------------------------------------------------- 1 | Docker documentation and website 2 | ================================ 3 | 4 | Documentation 5 | ------------- 6 | This is your definite place to contribute to the docker documentation. The documentation is generated from the 7 | .rst files under sources. 8 | 9 | The folder also contains the other files to create the http://docker.io website, but you can generally ignore 10 | most of those. 11 | 12 | 13 | Installation 14 | ------------ 15 | 16 | * Work in your own fork of the code, we accept pull requests. 17 | * Install sphinx: `pip install sphinx` 18 | * Mac OS X: `[sudo] pip-2.7 install sphinx`) 19 | * Install sphinx httpdomain contrib package: `pip install sphinxcontrib-httpdomain` 20 | * Mac OS X: `[sudo] pip-2.7 install sphinxcontrib-httpdomain` 21 | * If pip is not available you can probably install it using your favorite package manager as **python-pip** 22 | 23 | Usage 24 | ----- 25 | * Change the `.rst` files with your favorite editor to your liking. 26 | * Run `make docs` to clean up old files and generate new ones. 27 | * Your static website can now be found in the `_build` directory. 28 | * To preview what you have generated run `make server` and open in your favorite browser. 29 | 30 | Working using GitHub's file editor 31 | ---------------------------------- 32 | Alternatively, for small changes and typo's you might want to use GitHub's built in file editor. It allows 33 | you to preview your changes right online. Just be carefull not to create many commits. 34 | 35 | Images 36 | ------ 37 | When you need to add images, try to make them as small as possible (e.g. as gif). 38 | 39 | 40 | Notes 41 | ----- 42 | * The index.html and gettingstarted.html files are copied from the source dir to the output dir without modification. 43 | So changes to those pages should be made directly in html 44 | * For the template the css is compiled from less. When changes are needed they can be compiled using 45 | lessc ``lessc main.less`` or watched using watch-lessc ``watch-lessc -i main.less -o main.css`` 46 | 47 | 48 | Guides on using sphinx 49 | ---------------------- 50 | * To make links to certain pages create a link target like so: 51 | 52 | ``` 53 | .. _hello_world: 54 | 55 | Hello world 56 | =========== 57 | 58 | This is.. (etc.) 59 | ``` 60 | 61 | The ``_hello_world:`` will make it possible to link to this position (page and marker) from all other pages. 62 | 63 | * Notes, warnings and alarms 64 | 65 | ``` 66 | # a note (use when something is important) 67 | .. note:: 68 | 69 | # a warning (orange) 70 | .. warning:: 71 | 72 | # danger (red, use sparsely) 73 | .. danger:: 74 | 75 | * Code examples 76 | 77 | Start without $, so it's easy to copy and paste. 78 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | DOCKER_PACKAGE := github.com/dotcloud/docker 2 | RELEASE_VERSION := $(shell git tag | grep -E "v[0-9\.]+$$" | sort -nr | head -n 1) 3 | SRCRELEASE := docker-$(RELEASE_VERSION) 4 | BINRELEASE := docker-$(RELEASE_VERSION).tgz 5 | 6 | GIT_ROOT := $(shell git rev-parse --show-toplevel) 7 | BUILD_DIR := $(CURDIR)/.gopath 8 | 9 | GOPATH ?= $(BUILD_DIR) 10 | export GOPATH 11 | 12 | GO_OPTIONS ?= 13 | ifeq ($(VERBOSE), 1) 14 | GO_OPTIONS += -v 15 | endif 16 | 17 | GIT_COMMIT = $(shell git rev-parse --short HEAD) 18 | GIT_STATUS = $(shell test -n "`git status --porcelain`" && echo "+CHANGES") 19 | 20 | BUILD_OPTIONS = -a -ldflags "-X main.GITCOMMIT $(GIT_COMMIT)$(GIT_STATUS) -d -w" 21 | 22 | SRC_DIR := $(GOPATH)/src 23 | 24 | DOCKER_DIR := $(SRC_DIR)/$(DOCKER_PACKAGE) 25 | DOCKER_MAIN := $(DOCKER_DIR)/docker 26 | 27 | DOCKER_BIN_RELATIVE := bin/docker 28 | DOCKER_BIN := $(CURDIR)/$(DOCKER_BIN_RELATIVE) 29 | 30 | .PHONY: all clean test hack release srcrelease $(BINRELEASE) $(SRCRELEASE) $(DOCKER_BIN) $(DOCKER_DIR) 31 | 32 | all: $(DOCKER_BIN) 33 | 34 | $(DOCKER_BIN): $(DOCKER_DIR) 35 | @mkdir -p $(dir $@) 36 | @(cd $(DOCKER_MAIN); CGO_ENABLED=0 go build $(GO_OPTIONS) $(BUILD_OPTIONS) -o $@) 37 | @echo $(DOCKER_BIN_RELATIVE) is created. 38 | 39 | $(DOCKER_DIR): 40 | @mkdir -p $(dir $@) 41 | @if [ -h $@ ]; then rm -f $@; fi; ln -sf $(CURDIR)/ $@ 42 | @(cd $(DOCKER_MAIN); go get -d $(GO_OPTIONS)) 43 | 44 | whichrelease: 45 | echo $(RELEASE_VERSION) 46 | 47 | release: $(BINRELEASE) 48 | s3cmd -P put $(BINRELEASE) s3://get.docker.io/builds/`uname -s`/`uname -m`/docker-$(RELEASE_VERSION).tgz 49 | s3cmd -P put docker-latest.tgz s3://get.docker.io/builds/`uname -s`/`uname -m`/docker-latest.tgz 50 | 51 | srcrelease: $(SRCRELEASE) 52 | deps: $(DOCKER_DIR) 53 | 54 | # A clean checkout of $RELEASE_VERSION, with vendored dependencies 55 | $(SRCRELEASE): 56 | rm -fr $(SRCRELEASE) 57 | git clone $(GIT_ROOT) $(SRCRELEASE) 58 | cd $(SRCRELEASE); git checkout -q $(RELEASE_VERSION) 59 | 60 | # A binary release ready to be uploaded to a mirror 61 | $(BINRELEASE): $(SRCRELEASE) 62 | rm -f $(BINRELEASE) 63 | cd $(SRCRELEASE); make; cp -R bin docker-$(RELEASE_VERSION); tar -f ../$(BINRELEASE) -zv -c docker-$(RELEASE_VERSION) 64 | cd $(SRCRELEASE); cp -R bin docker-latest; tar -f ../docker-latest.tgz -zv -c docker-latest 65 | 66 | clean: 67 | @rm -rf $(dir $(DOCKER_BIN)) 68 | ifeq ($(GOPATH), $(BUILD_DIR)) 69 | @rm -rf $(BUILD_DIR) 70 | else ifneq ($(DOCKER_DIR), $(realpath $(DOCKER_DIR))) 71 | @rm -f $(DOCKER_DIR) 72 | endif 73 | 74 | test: all 75 | @(cd $(DOCKER_DIR); sudo -E go test $(GO_OPTIONS)) 76 | 77 | testall: all 78 | @(cd $(DOCKER_DIR); sudo -E go test ./... $(GO_OPTIONS)) 79 | 80 | fmt: 81 | @gofmt -s -l -w . 82 | 83 | hack: 84 | cd $(CURDIR)/hack && vagrant up 85 | 86 | ssh-dev: 87 | cd $(CURDIR)/hack && vagrant ssh 88 | -------------------------------------------------------------------------------- /changes.go: -------------------------------------------------------------------------------- 1 | package docker 2 | 3 | import ( 4 | "fmt" 5 | "os" 6 | "path/filepath" 7 | "strings" 8 | ) 9 | 10 | type ChangeType int 11 | 12 | const ( 13 | ChangeModify = iota 14 | ChangeAdd 15 | ChangeDelete 16 | ) 17 | 18 | type Change struct { 19 | Path string 20 | Kind ChangeType 21 | } 22 | 23 | func (change *Change) String() string { 24 | var kind string 25 | switch change.Kind { 26 | case ChangeModify: 27 | kind = "C" 28 | case ChangeAdd: 29 | kind = "A" 30 | case ChangeDelete: 31 | kind = "D" 32 | } 33 | return fmt.Sprintf("%s %s", kind, change.Path) 34 | } 35 | 36 | func Changes(layers []string, rw string) ([]Change, error) { 37 | var changes []Change 38 | err := filepath.Walk(rw, func(path string, f os.FileInfo, err error) error { 39 | if err != nil { 40 | return err 41 | } 42 | 43 | // Rebase path 44 | path, err = filepath.Rel(rw, path) 45 | if err != nil { 46 | return err 47 | } 48 | path = filepath.Join("/", path) 49 | 50 | // Skip root 51 | if path == "/" { 52 | return nil 53 | } 54 | 55 | // Skip AUFS metadata 56 | if matched, err := filepath.Match("/.wh..wh.*", path); err != nil || matched { 57 | return err 58 | } 59 | 60 | change := Change{ 61 | Path: path, 62 | } 63 | 64 | // Find out what kind of modification happened 65 | file := filepath.Base(path) 66 | // If there is a whiteout, then the file was removed 67 | if strings.HasPrefix(file, ".wh.") { 68 | originalFile := file[len(".wh."):] 69 | change.Path = filepath.Join(filepath.Dir(path), originalFile) 70 | change.Kind = ChangeDelete 71 | } else { 72 | // Otherwise, the file was added 73 | change.Kind = ChangeAdd 74 | 75 | // ...Unless it already existed in a top layer, in which case, it's a modification 76 | for _, layer := range layers { 77 | stat, err := os.Stat(filepath.Join(layer, path)) 78 | if err != nil && !os.IsNotExist(err) { 79 | return err 80 | } 81 | if err == nil { 82 | // The file existed in the top layer, so that's a modification 83 | 84 | // However, if it's a directory, maybe it wasn't actually modified. 85 | // If you modify /foo/bar/baz, then /foo will be part of the changed files only because it's the parent of bar 86 | if stat.IsDir() && f.IsDir() { 87 | if f.Size() == stat.Size() && f.Mode() == stat.Mode() && f.ModTime() == stat.ModTime() { 88 | // Both directories are the same, don't record the change 89 | return nil 90 | } 91 | } 92 | change.Kind = ChangeModify 93 | break 94 | } 95 | } 96 | } 97 | 98 | // Record change 99 | changes = append(changes, change) 100 | return nil 101 | }) 102 | if err != nil { 103 | return nil, err 104 | } 105 | return changes, nil 106 | } 107 | -------------------------------------------------------------------------------- /docs/sources/examples/hello_world_daemon.rst: -------------------------------------------------------------------------------- 1 | :title: Hello world daemon example 2 | :description: A simple hello world daemon example with Docker 3 | :keywords: docker, example, hello world, daemon 4 | 5 | .. _hello_world_daemon: 6 | 7 | Hello World Daemon 8 | ================== 9 | 10 | .. include:: example_header.inc 11 | 12 | The most boring daemon ever written. 13 | 14 | This example assumes you have Docker installed and with the base image already imported ``docker pull base``. 15 | We will use the base image to run a simple hello world daemon that will just print hello world to standard 16 | out every second. It will continue to do this until we stop it. 17 | 18 | **Steps:** 19 | 20 | .. code-block:: bash 21 | 22 | CONTAINER_ID=$(docker run -d base /bin/sh -c "while true; do echo hello world; sleep 1; done") 23 | 24 | We are going to run a simple hello world daemon in a new container made from the base image. 25 | 26 | - **"docker run -d "** run a command in a new container. We pass "-d" so it runs as a daemon. 27 | - **"base"** is the image we want to run the command inside of. 28 | - **"/bin/sh -c"** is the command we want to run in the container 29 | - **"while true; do echo hello world; sleep 1; done"** is the mini script we want to run, that will just print hello world once a second until we stop it. 30 | - **$CONTAINER_ID** the output of the run command will return a container id, we can use in future commands to see what is going on with this process. 31 | 32 | .. code-block:: bash 33 | 34 | docker logs $CONTAINER_ID 35 | 36 | Check the logs make sure it is working correctly. 37 | 38 | - **"docker logs**" This will return the logs for a container 39 | - **$CONTAINER_ID** The Id of the container we want the logs for. 40 | 41 | .. code-block:: bash 42 | 43 | docker attach $CONTAINER_ID 44 | 45 | Attach to the container to see the results in realtime. 46 | 47 | - **"docker attach**" This will allow us to attach to a background process to see what is going on. 48 | - **$CONTAINER_ID** The Id of the container we want to attach too. 49 | 50 | .. code-block:: bash 51 | 52 | docker ps 53 | 54 | Check the process list to make sure it is running. 55 | 56 | - **"docker ps"** this shows all running process managed by docker 57 | 58 | .. code-block:: bash 59 | 60 | docker stop $CONTAINER_ID 61 | 62 | Stop the container, since we don't need it anymore. 63 | 64 | - **"docker stop"** This stops a container 65 | - **$CONTAINER_ID** The Id of the container we want to stop. 66 | 67 | .. code-block:: bash 68 | 69 | docker ps 70 | 71 | Make sure it is really stopped. 72 | 73 | 74 | **Video:** 75 | 76 | See the example in action 77 | 78 | .. raw:: html 79 | 80 |
    81 | 82 |
    83 | 84 | Continue to the :ref:`python_web_app` example. 85 | -------------------------------------------------------------------------------- /docs/sources/examples/running_ssh_service.rst: -------------------------------------------------------------------------------- 1 | :title: Running an SSH service 2 | :description: A screencast of installing and running an sshd service 3 | :keywords: docker, example, package installation, networking 4 | 5 | .. _running_ssh_service: 6 | 7 | SSH Daemon Service 8 | ================== 9 | 10 | .. include:: example_header.inc 11 | 12 | 13 | **Video:** 14 | 15 | I've create a little screencast to show how to create a sshd service and connect to it. It is something like 11 16 | minutes and not entirely smooth, but gives you a good idea. 17 | 18 | .. raw:: html 19 | 20 |
    21 | 22 |
    23 | 24 | You can also get this sshd container by using 25 | :: 26 | 27 | docker pull dhrp/sshd 28 | 29 | 30 | The password is 'screencast' 31 | 32 | **Video's Transcription:** 33 | 34 | .. code-block:: bash 35 | 36 | # Hello! We are going to try and install openssh on a container and run it as a servic 37 | # let's pull base to get a base ubuntu image. 38 | $ docker pull base 39 | # I had it so it was quick 40 | # now let's connect using -i for interactive and with -t for terminal 41 | # we execute /bin/bash to get a prompt. 42 | $ docker run -i -t base /bin/bash 43 | # now let's commit it 44 | # which container was it? 45 | $ docker ps -a |more 46 | $ docker commit a30a3a2f2b130749995f5902f079dc6ad31ea0621fac595128ec59c6da07feea dhrp/sshd 47 | # I gave the name dhrp/sshd for the container 48 | # now we can run it again 49 | $ docker run -d dhrp/sshd /usr/sbin/sshd -D # D for daemon mode 50 | # is it running? 51 | $ docker ps 52 | # yes! 53 | # let's stop it 54 | $ docker stop 0ebf7cec294755399d063f4b1627980d4cbff7d999f0bc82b59c300f8536a562 55 | $ docker ps 56 | # and reconnect, but now open a port to it 57 | $ docker run -d -p 22 dhrp/sshd /usr/sbin/sshd -D 58 | $ docker port b2b407cf22cf8e7fa3736fa8852713571074536b1d31def3fdfcd9fa4fd8c8c5 22 59 | # it has now given us a port to connect to 60 | # we have to connect using a public ip of our host 61 | $ hostname 62 | # *ifconfig* is deprecated, better use *ip addr show* now 63 | $ ifconfig 64 | $ ssh root@192.168.33.10 -p 49153 65 | # Ah! forgot to set root passwd 66 | $ docker commit b2b407cf22cf8e7fa3736fa8852713571074536b1d31def3fdfcd9fa4fd8c8c5 dhrp/sshd 67 | $ docker ps -a 68 | $ docker run -i -t dhrp/sshd /bin/bash 69 | $ passwd 70 | $ exit 71 | $ docker commit 9e863f0ca0af31c8b951048ba87641d67c382d08d655c2e4879c51410e0fedc1 dhrp/sshd 72 | $ docker run -d -p 22 dhrp/sshd /usr/sbin/sshd -D 73 | $ docker port a0aaa9558c90cf5c7782648df904a82365ebacce523e4acc085ac1213bfe2206 22 74 | # *ifconfig* is deprecated, better use *ip addr show* now 75 | $ ifconfig 76 | $ ssh root@192.168.33.10 -p 49154 77 | # Thanks for watching, Thatcher thatcher@dotcloud.com 78 | 79 | 80 | -------------------------------------------------------------------------------- /docs/sources/installation/amazon.rst: -------------------------------------------------------------------------------- 1 | :title: Installation on Amazon EC2 2 | :description: Docker installation on Amazon EC2 with a single vagrant command. Vagrant 1.1 or higher is required. 3 | :keywords: amazon ec2, virtualization, cloud, docker, documentation, installation 4 | 5 | Amazon EC2 6 | ========== 7 | 8 | Please note this is a community contributed installation path. The only 'official' installation is using the 9 | :ref:`ubuntu_linux` installation path. This version may sometimes be out of date. 10 | 11 | 12 | Installation 13 | ------------ 14 | 15 | Docker can now be installed on Amazon EC2 with a single vagrant command. Vagrant 1.1 or higher is required. 16 | 17 | 1. Install vagrant from http://www.vagrantup.com/ (or use your package manager) 18 | 2. Install the vagrant aws plugin 19 | 20 | :: 21 | 22 | vagrant plugin install vagrant-aws 23 | 24 | 25 | 3. Get the docker sources, this will give you the latest Vagrantfile. 26 | 27 | :: 28 | 29 | git clone https://github.com/dotcloud/docker.git 30 | 31 | 32 | 4. Check your AWS environment. 33 | 34 | Create a keypair specifically for EC2, give it a name and save it to your disk. *I usually store these in my ~/.ssh/ folder*. 35 | 36 | Check that your default security group has an inbound rule to accept SSH (port 22) connections. 37 | 38 | 39 | 40 | 5. Inform Vagrant of your settings 41 | 42 | Vagrant will read your access credentials from your environment, so we need to set them there first. Make sure 43 | you have everything on amazon aws setup so you can (manually) deploy a new image to EC2. 44 | 45 | :: 46 | 47 | export AWS_ACCESS_KEY_ID=xxx 48 | export AWS_SECRET_ACCESS_KEY=xxx 49 | export AWS_KEYPAIR_NAME=xxx 50 | export AWS_SSH_PRIVKEY=xxx 51 | 52 | The environment variables are: 53 | 54 | * ``AWS_ACCESS_KEY_ID`` - The API key used to make requests to AWS 55 | * ``AWS_SECRET_ACCESS_KEY`` - The secret key to make AWS API requests 56 | * ``AWS_KEYPAIR_NAME`` - The name of the keypair used for this EC2 instance 57 | * ``AWS_SSH_PRIVKEY`` - The path to the private key for the named keypair, for example ``~/.ssh/docker.pem`` 58 | 59 | You can check if they are set correctly by doing something like 60 | 61 | :: 62 | 63 | echo $AWS_ACCESS_KEY_ID 64 | 65 | 6. Do the magic! 66 | 67 | :: 68 | 69 | vagrant up --provider=aws 70 | 71 | 72 | If it stalls indefinitely on ``[default] Waiting for SSH to become available...``, Double check your default security 73 | zone on AWS includes rights to SSH (port 22) to your container. 74 | 75 | If you have an advanced AWS setup, you might want to have a look at https://github.com/mitchellh/vagrant-aws 76 | 77 | 7. Connect to your machine 78 | 79 | .. code-block:: bash 80 | 81 | vagrant ssh 82 | 83 | 8. Your first command 84 | 85 | Now you are in the VM, run docker 86 | 87 | .. code-block:: bash 88 | 89 | docker 90 | 91 | 92 | Continue with the :ref:`hello_world` example. -------------------------------------------------------------------------------- /packaging/ubuntu/Makefile: -------------------------------------------------------------------------------- 1 | # Ubuntu package Makefile 2 | # 3 | # Dependencies: debhelper autotools-dev devscripts golang-stable 4 | # Notes: 5 | # Use 'make ubuntu' to create the ubuntu package and push it to stating PPA by 6 | # default. To push to production, set PUBLISH_PPA=1 before doing 'make ubuntu' 7 | # GPG_KEY environment variable needs to contain a GPG private key for package 8 | # to be signed and uploaded to docker PPA. If GPG_KEY is not defined, 9 | # make ubuntu will create docker package and exit with status code 2 10 | 11 | PKG_NAME=lxc-docker 12 | GITHUB_PATH=github.com/dotcloud/docker 13 | BUILD_SRC=${CURDIR}/../../build_src 14 | VERSION=$(shell sed -En '0,/^\#\# /{s/^\#\# ([^ ]+).+/\1/p}' ../../CHANGELOG.md) 15 | 16 | all: 17 | # Compile docker. Used by dpkg-buildpackage. 18 | cd src/${GITHUB_PATH}/docker; GOPATH=${CURDIR} CGO_ENABLED=0 go build -a -ldflags '-d -w' 19 | 20 | install: 21 | # Used by dpkg-buildpackage 22 | mkdir -p ${DESTDIR}/usr/bin 23 | mkdir -p ${DESTDIR}/etc/init 24 | mkdir -p ${DESTDIR}/DEBIAN 25 | install -m 0755 src/${GITHUB_PATH}/docker/docker ${DESTDIR}/usr/bin 26 | install -o root -m 0644 debian/docker.upstart ${DESTDIR}/etc/init/docker.conf 27 | install debian/lxc-docker.prerm ${DESTDIR}/DEBIAN/prerm 28 | install debian/lxc-docker.postinst ${DESTDIR}/DEBIAN/postinst 29 | 30 | ubuntu: 31 | # This Makefile will compile the github master branch of dotcloud/docker 32 | # Retrieve docker project and its go structure from internet 33 | rm -rf ${BUILD_SRC} 34 | git clone $(shell git rev-parse --show-toplevel) ${BUILD_SRC}/${GITHUB_PATH} 35 | cd ${BUILD_SRC}/${GITHUB_PATH}; git checkout v${VERSION} && GOPATH=${BUILD_SRC} go get -d 36 | # Add debianization 37 | mkdir ${BUILD_SRC}/debian 38 | cp Makefile ${BUILD_SRC} 39 | cp -r * ${BUILD_SRC}/debian 40 | cp ../../README.md ${BUILD_SRC} 41 | ./parse_changelog.py < ../../CHANGELOG.md > ${BUILD_SRC}/debian/changelog 42 | # Cleanup 43 | for d in `find ${BUILD_SRC} -name '.git*'`; do rm -rf $$d; done 44 | rm -rf ${BUILD_SRC}/../${PKG_NAME}_${VERSION}.orig.tar.gz 45 | rm -rf ${BUILD_SRC}/pkg 46 | # Create docker debian files 47 | cd ${BUILD_SRC}; tar czf ../${PKG_NAME}_${VERSION}.orig.tar.gz . 48 | cd ${BUILD_SRC}; dpkg-buildpackage -us -uc 49 | rm -rf ${BUILD_SRC} 50 | # Sign package and upload it to PPA if GPG_KEY environment variable 51 | # holds a private GPG KEY 52 | if /usr/bin/test "$${GPG_KEY}" == ""; then exit 2; fi 53 | mkdir ${BUILD_SRC} 54 | # Import gpg signing key 55 | echo "$${GPG_KEY}" | gpg --allow-secret-key-import --import || true 56 | # Sign the package 57 | cd ${BUILD_SRC}; dpkg-source -x ${BUILD_SRC}/../${PKG_NAME}_${VERSION}-1.dsc 58 | cd ${BUILD_SRC}/${PKG_NAME}-${VERSION}; debuild -S -sa 59 | # Upload to PPA 60 | if [ "${PUBLISH_PPA}" = "1" ]; then cd ${BUILD_SRC};dput ppa:dotcloud/lxc-docker ${PKG_NAME}_${VERSION}-1_source.changes; fi 61 | if [ "${PUBLISH_PPA}" != "1" ]; then cd ${BUILD_SRC};dput ppa:dotcloud/docker-staging ${PKG_NAME}_${VERSION}-1_source.changes; fi 62 | rm -rf ${BUILD_SRC} 63 | -------------------------------------------------------------------------------- /contrib/crashTest.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "io" 6 | "log" 7 | "net" 8 | "os" 9 | "os/exec" 10 | "path" 11 | "time" 12 | ) 13 | 14 | var DOCKERPATH = path.Join(os.Getenv("DOCKERPATH"), "docker") 15 | 16 | // WARNING: this crashTest will 1) crash your host, 2) remove all containers 17 | func runDaemon() (*exec.Cmd, error) { 18 | os.Remove("/var/run/docker.pid") 19 | exec.Command("rm", "-rf", "/var/lib/docker/containers").Run() 20 | cmd := exec.Command(DOCKERPATH, "-d") 21 | outPipe, err := cmd.StdoutPipe() 22 | if err != nil { 23 | return nil, err 24 | } 25 | errPipe, err := cmd.StderrPipe() 26 | if err != nil { 27 | return nil, err 28 | } 29 | if err := cmd.Start(); err != nil { 30 | return nil, err 31 | } 32 | go func() { 33 | io.Copy(os.Stdout, outPipe) 34 | }() 35 | go func() { 36 | io.Copy(os.Stderr, errPipe) 37 | }() 38 | return cmd, nil 39 | } 40 | 41 | func crashTest() error { 42 | if err := exec.Command("/bin/bash", "-c", "while true; do true; done").Start(); err != nil { 43 | return err 44 | } 45 | 46 | var endpoint string 47 | if ep := os.Getenv("TEST_ENDPOINT"); ep == "" { 48 | endpoint = "192.168.56.1:7979" 49 | } else { 50 | endpoint = ep 51 | } 52 | 53 | c := make(chan bool) 54 | var conn io.Writer 55 | 56 | go func() { 57 | conn, _ = net.Dial("tcp", endpoint) 58 | c <- false 59 | }() 60 | go func() { 61 | time.Sleep(2 * time.Second) 62 | c <- true 63 | }() 64 | <-c 65 | 66 | restartCount := 0 67 | totalTestCount := 1 68 | for { 69 | daemon, err := runDaemon() 70 | if err != nil { 71 | return err 72 | } 73 | restartCount++ 74 | // time.Sleep(5000 * time.Millisecond) 75 | var stop bool 76 | go func() error { 77 | stop = false 78 | for i := 0; i < 100 && !stop; { 79 | func() error { 80 | cmd := exec.Command(DOCKERPATH, "run", "base", "echo", fmt.Sprintf("%d", totalTestCount)) 81 | i++ 82 | totalTestCount++ 83 | outPipe, err := cmd.StdoutPipe() 84 | if err != nil { 85 | return err 86 | } 87 | inPipe, err := cmd.StdinPipe() 88 | if err != nil { 89 | return err 90 | } 91 | if err := cmd.Start(); err != nil { 92 | return err 93 | } 94 | if conn != nil { 95 | go io.Copy(conn, outPipe) 96 | } 97 | 98 | // Expecting error, do not check 99 | inPipe.Write([]byte("hello world!!!!!\n")) 100 | go inPipe.Write([]byte("hello world!!!!!\n")) 101 | go inPipe.Write([]byte("hello world!!!!!\n")) 102 | inPipe.Close() 103 | 104 | if err := cmd.Wait(); err != nil { 105 | return err 106 | } 107 | outPipe.Close() 108 | return nil 109 | }() 110 | } 111 | return nil 112 | }() 113 | time.Sleep(20 * time.Second) 114 | stop = true 115 | if err := daemon.Process.Kill(); err != nil { 116 | return err 117 | } 118 | } 119 | } 120 | 121 | func main() { 122 | if err := crashTest(); err != nil { 123 | log.Println(err) 124 | } 125 | } 126 | -------------------------------------------------------------------------------- /docs/sources/installation/rackspace.rst: -------------------------------------------------------------------------------- 1 | :title: Rackspace Cloud Installation 2 | :description: Installing Docker on Ubuntu proviced by Rackspace 3 | :keywords: Rackspace Cloud, installation, docker, linux, ubuntu 4 | 5 | =============== 6 | Rackspace Cloud 7 | =============== 8 | 9 | Please note this is a community contributed installation path. The only 'official' installation is using the 10 | :ref:`ubuntu_linux` installation path. This version may sometimes be out of date. 11 | 12 | 13 | Installing Docker on Ubuntu proviced by Rackspace is pretty straightforward, and you should mostly be able to follow the 14 | :ref:`ubuntu_linux` installation guide. 15 | 16 | **However, there is one caveat:** 17 | 18 | If you are using any linux not already shipping with the 3.8 kernel you will need to install it. And this is a little 19 | more difficult on Rackspace. 20 | 21 | Rackspace boots their servers using grub's menu.lst and does not like non 'virtual' packages (e.g. xen compatible) 22 | kernels there, although they do work. This makes ``update-grub`` to not have the expected result, and you need to 23 | set the kernel manually. 24 | 25 | **Do not attempt this on a production machine!** 26 | 27 | .. code-block:: bash 28 | 29 | # update apt 30 | apt-get update 31 | 32 | # install the new kernel 33 | apt-get install linux-generic-lts-raring 34 | 35 | 36 | Great, now you have kernel installed in /boot/, next is to make it boot next time. 37 | 38 | .. code-block:: bash 39 | 40 | # find the exact names 41 | find /boot/ -name '*3.8*' 42 | 43 | # this should return some results 44 | 45 | 46 | Now you need to manually edit /boot/grub/menu.lst, you will find a section at the bottom with the existing options. 47 | Copy the top one and substitute the new kernel into that. Make sure the new kernel is on top, and double check kernel 48 | and initrd point to the right files. 49 | 50 | Make special care to double check the kernel and initrd entries. 51 | 52 | .. code-block:: bash 53 | 54 | # now edit /boot/grub/menu.lst 55 | vi /boot/grub/menu.lst 56 | 57 | It will probably look something like this: 58 | 59 | :: 60 | 61 | ## ## End Default Options ## 62 | 63 | title Ubuntu 12.04.2 LTS, kernel 3.8.x generic 64 | root (hd0) 65 | kernel /boot/vmlinuz-3.8.0-19-generic root=/dev/xvda1 ro quiet splash console=hvc0 66 | initrd /boot/initrd.img-3.8.0-19-generic 67 | 68 | title Ubuntu 12.04.2 LTS, kernel 3.2.0-38-virtual 69 | root (hd0) 70 | kernel /boot/vmlinuz-3.2.0-38-virtual root=/dev/xvda1 ro quiet splash console=hvc0 71 | initrd /boot/initrd.img-3.2.0-38-virtual 72 | 73 | title Ubuntu 12.04.2 LTS, kernel 3.2.0-38-virtual (recovery mode) 74 | root (hd0) 75 | kernel /boot/vmlinuz-3.2.0-38-virtual root=/dev/xvda1 ro quiet splash single 76 | initrd /boot/initrd.img-3.2.0-38-virtual 77 | 78 | 79 | Reboot server (either via command line or console) 80 | 81 | .. code-block:: bash 82 | 83 | # reboot 84 | 85 | Verify the kernel was updated 86 | 87 | .. code-block:: bash 88 | 89 | uname -a 90 | # Linux docker-12-04 3.8.0-19-generic #30~precise1-Ubuntu SMP Wed May 1 22:26:36 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux 91 | 92 | # nice! 3.8. 93 | 94 | 95 | Now you can finish with the :ref:`ubuntu_linux` instructions. -------------------------------------------------------------------------------- /docs/sources/use/puppet.rst: -------------------------------------------------------------------------------- 1 | :title: Puppet Usage 2 | :description: Installating and using Puppet 3 | :keywords: puppet, installation, usage, docker, documentation 4 | 5 | .. _install_using_puppet: 6 | 7 | Using Puppet 8 | ============= 9 | 10 | .. note:: 11 | 12 | Please note this is a community contributed installation path. The only 'official' installation is using the 13 | :ref:`ubuntu_linux` installation path. This version may sometimes be out of date. 14 | 15 | Requirements 16 | ------------ 17 | 18 | To use this guide you'll need a working installation of Puppet from `Puppetlabs `_ . 19 | 20 | The module also currently uses the official PPA so only works with Ubuntu. 21 | 22 | Installation 23 | ------------ 24 | 25 | The module is available on the `Puppet Forge `_ 26 | and can be installed using the built-in module tool. 27 | 28 | .. code-block:: bash 29 | 30 | puppet module install garethr/docker 31 | 32 | It can also be found on `GitHub `_ 33 | if you would rather download the source. 34 | 35 | Usage 36 | ----- 37 | 38 | The module provides a puppet class for installing docker and two defined types 39 | for managing images and containers. 40 | 41 | Installation 42 | ~~~~~~~~~~~~ 43 | 44 | .. code-block:: ruby 45 | 46 | include 'docker' 47 | 48 | Images 49 | ~~~~~~ 50 | 51 | The next step is probably to install a docker image, for this we have a 52 | defined type which can be used like so: 53 | 54 | .. code-block:: ruby 55 | 56 | docker::image { 'base': } 57 | 58 | This is equivalent to running: 59 | 60 | .. code-block:: bash 61 | 62 | docker pull base 63 | 64 | Note that it will only if the image of that name does not already exist. 65 | This is downloading a large binary so on first run can take a while. 66 | For that reason this define turns off the default 5 minute timeout 67 | for exec. Note that you can also remove images you no longer need with: 68 | 69 | .. code-block:: ruby 70 | 71 | docker::image { 'base': 72 | ensure => 'absent', 73 | } 74 | 75 | Containers 76 | ~~~~~~~~~~ 77 | 78 | Now you have an image you can run commands within a container managed by 79 | docker. 80 | 81 | .. code-block:: ruby 82 | 83 | docker::run { 'helloworld': 84 | image => 'base', 85 | command => '/bin/sh -c "while true; do echo hello world; sleep 1; done"', 86 | } 87 | 88 | This is equivalent to running the following command, but under upstart: 89 | 90 | .. code-block:: bash 91 | 92 | docker run -d base /bin/sh -c "while true; do echo hello world; sleep 1; done" 93 | 94 | Run also contains a number of optional parameters: 95 | 96 | .. code-block:: ruby 97 | 98 | docker::run { 'helloworld': 99 | image => 'base', 100 | command => '/bin/sh -c "while true; do echo hello world; sleep 1; done"', 101 | ports => ['4444', '4555'], 102 | volumes => ['/var/lib/counchdb', '/var/log'], 103 | volumes_from => '6446ea52fbc9', 104 | memory_limit => 10485760, # bytes 105 | username => 'example', 106 | hostname => 'example.com', 107 | env => ['FOO=BAR', 'FOO2=BAR2'], 108 | dns => ['8.8.8.8', '8.8.4.4'], 109 | } 110 | 111 | Note that ports, env, dns and volumes can be set with either a single string 112 | or as above with an array of values. 113 | -------------------------------------------------------------------------------- /docs/sources/examples/python_web_app.rst: -------------------------------------------------------------------------------- 1 | :title: Python Web app example 2 | :description: Building your own python web app using docker 3 | :keywords: docker, example, python, web app 4 | 5 | .. _python_web_app: 6 | 7 | Python Web App 8 | ============== 9 | 10 | .. include:: example_header.inc 11 | 12 | The goal of this example is to show you how you can author your own docker images using a parent image, making changes to it, and then saving the results as a new image. We will do that by making a simple hello flask web application image. 13 | 14 | **Steps:** 15 | 16 | .. code-block:: bash 17 | 18 | docker pull shykes/pybuilder 19 | 20 | We are downloading the "shykes/pybuilder" docker image 21 | 22 | .. code-block:: bash 23 | 24 | URL=http://github.com/shykes/helloflask/archive/master.tar.gz 25 | 26 | We set a URL variable that points to a tarball of a simple helloflask web app 27 | 28 | .. code-block:: bash 29 | 30 | BUILD_JOB=$(docker run -d -t shykes/pybuilder:latest /usr/local/bin/buildapp $URL) 31 | 32 | Inside of the "shykes/pybuilder" image there is a command called buildapp, we are running that command and passing the $URL variable from step 2 to it, and running the whole thing inside of a new container. BUILD_JOB will be set with the new container_id. 33 | 34 | .. code-block:: bash 35 | 36 | docker attach $BUILD_JOB 37 | [...] 38 | 39 | We attach to the new container to see what is going on. Ctrl-C to disconnect 40 | 41 | .. code-block:: bash 42 | 43 | BUILD_IMG=$(docker commit $BUILD_JOB _/builds/github.com/shykes/helloflask/master) 44 | 45 | Save the changed we just made in the container to a new image called "_/builds/github.com/hykes/helloflask/master" and save the image id in the BUILD_IMG variable name. 46 | 47 | .. code-block:: bash 48 | 49 | WEB_WORKER=$(docker run -d -p 5000 $BUILD_IMG /usr/local/bin/runapp) 50 | 51 | - **"docker run -d "** run a command in a new container. We pass "-d" so it runs as a daemon. 52 | - **"-p 5000"** the web app is going to listen on this port, so it must be mapped from the container to the host system. 53 | - **"$BUILD_IMG"** is the image we want to run the command inside of. 54 | - **/usr/local/bin/runapp** is the command which starts the web app. 55 | 56 | Use the new image we just created and create a new container with network port 5000, and return the container id and store in the WEB_WORKER variable. 57 | 58 | .. code-block:: bash 59 | 60 | docker logs $WEB_WORKER 61 | * Running on http://0.0.0.0:5000/ 62 | 63 | view the logs for the new container using the WEB_WORKER variable, and if everything worked as planned you should see the line "Running on http://0.0.0.0:5000/" in the log output. 64 | 65 | .. code-block:: bash 66 | 67 | WEB_PORT=$(docker port $WEB_WORKER 5000) 68 | 69 | lookup the public-facing port which is NAT-ed store the private port used by the container and store it inside of the WEB_PORT variable. 70 | 71 | .. code-block:: bash 72 | 73 | # install curl if necessary, then ... 74 | curl http://127.0.0.1:$WEB_PORT 75 | Hello world! 76 | 77 | access the web app using curl. If everything worked as planned you should see the line "Hello world!" inside of your console. 78 | 79 | **Video:** 80 | 81 | See the example in action 82 | 83 | .. raw:: html 84 | 85 |
    86 | 87 |
    88 | 89 | Continue to :ref:`running_ssh_service`. 90 | -------------------------------------------------------------------------------- /docs/sources/use/workingwithrepository.rst: -------------------------------------------------------------------------------- 1 | :title: Working With Repositories 2 | :description: Generally, there are two types of repositories: Top-level repositories which are controlled by the people behind Docker, and user repositories. 3 | :keywords: repo, repositiores, usage, pull image, push image, image, documentation 4 | 5 | .. _working_with_the_repository: 6 | 7 | Working with the Repository 8 | =========================== 9 | 10 | 11 | Top-level repositories and user repositories 12 | -------------------------------------------- 13 | 14 | Generally, there are two types of repositories: Top-level repositories which are controlled by the people behind 15 | Docker, and user repositories. 16 | 17 | * Top-level repositories can easily be recognized by not having a ``/`` (slash) in their name. These repositories can 18 | generally be trusted. 19 | * User repositories always come in the form of ``/``. This is what your published images will look like. 20 | * User images are not checked, it is therefore up to you whether or not you trust the creator of this image. 21 | 22 | 23 | Find public images available on the index 24 | ----------------------------------------- 25 | 26 | Seach by name, namespace or description 27 | 28 | .. code-block:: bash 29 | 30 | docker search 31 | 32 | 33 | Download them simply by their name 34 | 35 | .. code-block:: bash 36 | 37 | docker pull 38 | 39 | 40 | Very similarly you can search for and browse the index online on https://index.docker.io 41 | 42 | 43 | Connecting to the repository 44 | ---------------------------- 45 | 46 | You can create a user on the central docker repository online, or by running 47 | 48 | .. code-block:: bash 49 | 50 | docker login 51 | 52 | 53 | If your username does not exist it will prompt you to also enter a password and your e-mail address. It will then 54 | automatically log you in. 55 | 56 | 57 | Committing a container to a named image 58 | --------------------------------------- 59 | 60 | In order to commit to the repository it is required to have committed your container to an image with your namespace. 61 | 62 | .. code-block:: bash 63 | 64 | # for example docker commit $CONTAINER_ID dhrp/kickassapp 65 | docker commit / 66 | 67 | 68 | Pushing a container to the repository 69 | ----------------------------------------- 70 | 71 | In order to push an image to the repository you need to have committed your container to a named image (see above) 72 | 73 | Now you can commit this image to the repository 74 | 75 | .. code-block:: bash 76 | 77 | # for example docker push dhrp/kickassapp 78 | docker push 79 | 80 | 81 | Changing the server to connect to 82 | ---------------------------------- 83 | 84 | When you are running your own index and/or registry, You can change the server the docker client will connect to. 85 | 86 | Variable 87 | ^^^^^^^^ 88 | 89 | .. code-block:: sh 90 | 91 | DOCKER_INDEX_URL 92 | 93 | Setting this environment variable on the docker server will change the URL docker index. 94 | This address is used in commands such as ``docker login``, ``docker push`` and ``docker pull``. 95 | The docker daemon doesn't need to be restarted for this parameter to take effect. 96 | 97 | Example 98 | ^^^^^^^ 99 | 100 | .. code-block:: sh 101 | 102 | docker -d & 103 | export DOCKER_INDEX_URL="https://index.docker.io" 104 | 105 | -------------------------------------------------------------------------------- /archive_test.go: -------------------------------------------------------------------------------- 1 | package docker 2 | 3 | import ( 4 | "bytes" 5 | "fmt" 6 | "io" 7 | "io/ioutil" 8 | "os" 9 | "os/exec" 10 | "path" 11 | "testing" 12 | "time" 13 | ) 14 | 15 | func TestCmdStreamLargeStderr(t *testing.T) { 16 | cmd := exec.Command("/bin/sh", "-c", "dd if=/dev/zero bs=1k count=1000 of=/dev/stderr; echo hello") 17 | out, err := CmdStream(cmd) 18 | if err != nil { 19 | t.Fatalf("Failed to start command: " + err.Error()) 20 | } 21 | errCh := make(chan error) 22 | go func() { 23 | _, err := io.Copy(ioutil.Discard, out) 24 | errCh <- err 25 | }() 26 | select { 27 | case err := <-errCh: 28 | if err != nil { 29 | t.Fatalf("Command should not have failed (err=%s...)", err.Error()[:100]) 30 | } 31 | case <-time.After(5 * time.Second): 32 | t.Fatalf("Command did not complete in 5 seconds; probable deadlock") 33 | } 34 | } 35 | 36 | func TestCmdStreamBad(t *testing.T) { 37 | badCmd := exec.Command("/bin/sh", "-c", "echo hello; echo >&2 error couldn\\'t reverse the phase pulser; exit 1") 38 | out, err := CmdStream(badCmd) 39 | if err != nil { 40 | t.Fatalf("Failed to start command: " + err.Error()) 41 | } 42 | if output, err := ioutil.ReadAll(out); err == nil { 43 | t.Fatalf("Command should have failed") 44 | } else if err.Error() != "exit status 1: error couldn't reverse the phase pulser\n" { 45 | t.Fatalf("Wrong error value (%s)", err.Error()) 46 | } else if s := string(output); s != "hello\n" { 47 | t.Fatalf("Command output should be '%s', not '%s'", "hello\\n", output) 48 | } 49 | } 50 | 51 | func TestCmdStreamGood(t *testing.T) { 52 | cmd := exec.Command("/bin/sh", "-c", "echo hello; exit 0") 53 | out, err := CmdStream(cmd) 54 | if err != nil { 55 | t.Fatal(err) 56 | } 57 | if output, err := ioutil.ReadAll(out); err != nil { 58 | t.Fatalf("Command should not have failed (err=%s)", err) 59 | } else if s := string(output); s != "hello\n" { 60 | t.Fatalf("Command output should be '%s', not '%s'", "hello\\n", output) 61 | } 62 | } 63 | 64 | func tarUntar(t *testing.T, origin string, compression Compression) error { 65 | archive, err := Tar(origin, compression) 66 | if err != nil { 67 | t.Fatal(err) 68 | } 69 | 70 | buf := make([]byte, 10) 71 | if _, err := archive.Read(buf); err != nil { 72 | return err 73 | } 74 | archive = io.MultiReader(bytes.NewReader(buf), archive) 75 | 76 | detectedCompression := DetectCompression(buf) 77 | if detectedCompression.Extension() != compression.Extension() { 78 | return fmt.Errorf("Wrong compression detected. Actual compression: %s, found %s", compression.Extension(), detectedCompression.Extension()) 79 | } 80 | 81 | tmp, err := ioutil.TempDir("", "docker-test-untar") 82 | if err != nil { 83 | return err 84 | } 85 | defer os.RemoveAll(tmp) 86 | if err := Untar(archive, tmp); err != nil { 87 | return err 88 | } 89 | if _, err := os.Stat(tmp); err != nil { 90 | return err 91 | } 92 | return nil 93 | } 94 | 95 | func TestTarUntar(t *testing.T) { 96 | origin, err := ioutil.TempDir("", "docker-test-untar-origin") 97 | if err != nil { 98 | t.Fatal(err) 99 | } 100 | defer os.RemoveAll(origin) 101 | if err := ioutil.WriteFile(path.Join(origin, "1"), []byte("hello world"), 0700); err != nil { 102 | t.Fatal(err) 103 | } 104 | if err := ioutil.WriteFile(path.Join(origin, "2"), []byte("welcome!"), 0700); err != nil { 105 | t.Fatal(err) 106 | } 107 | 108 | for _, c := range []Compression{ 109 | Uncompressed, 110 | Gzip, 111 | Bzip2, 112 | Xz, 113 | } { 114 | if err := tarUntar(t, origin, c); err != nil { 115 | t.Fatalf("Error tar/untar for compression %s: %s", c.Extension(), err) 116 | } 117 | } 118 | } 119 | -------------------------------------------------------------------------------- /AUTHORS: -------------------------------------------------------------------------------- 1 | # This file lists all individuals having contributed content to the repository. 2 | # If you're submitting a patch, please add your name here in alphabetical order as part of the patch. 3 | # 4 | # For a list of active project maintainers, see the MAINTAINERS file. 5 | # 6 | Al Tobey 7 | Alexey Shamrin 8 | Andrea Luzzardi 9 | Andreas Tiefenthaler 10 | Andrew Munsell 11 | Andy Rothfusz 12 | Andy Smith 13 | Antony Messerli 14 | Barry Allard 15 | Brandon Liu 16 | Brian McCallister 17 | Bruno Bigras 18 | Caleb Spare 19 | Calen Pennington 20 | Charles Hooper 21 | Christopher Currie 22 | Daniel Gasienica 23 | Daniel Mizyrycki 24 | Daniel Robinson 25 | Daniel Von Fange 26 | Dominik Honnef 27 | Don Spaulding 28 | Dr Nic Williams 29 | Elias Probst 30 | Eric Hanchrow 31 | Evan Wies 32 | Eric Myhre 33 | ezbercih 34 | Flavio Castelli 35 | Francisco Souza 36 | Frederick F. Kautz IV 37 | Gareth Rushgrove 38 | Guillaume J. Charmes 39 | Harley Laue 40 | Hunter Blanks 41 | Jeff Lindsay 42 | Jeremy Grosser 43 | Joffrey F 44 | John Costa 45 | Jon Wedaman 46 | Jonas Pfenniger 47 | Jonathan Rudenberg 48 | Joseph Anthony Pasquale Holsten 49 | Julien Barbier 50 | Jérôme Petazzoni 51 | Ken Cochrane 52 | Kevin J. Lynagh 53 | kim0 54 | Kiran Gangadharan 55 | Louis Opter 56 | Marcus Farkas 57 | Mark McGranaghan 58 | Maxim Treskin 59 | meejah 60 | Michael Crosby 61 | Mikhail Sobolev 62 | Nate Jones 63 | Nelson Chen 64 | Niall O'Higgins 65 | odk- 66 | Paul Bowsher 67 | Paul Hammond 68 | Phil Spitler 69 | Piotr Bogdan 70 | Renato Riccieri Santos Zannon 71 | Robert Obryk 72 | Roberto Hashioka 73 | Sam Alba 74 | Sam J Sharpe 75 | Shawn Siefkas 76 | Silas Sewell 77 | Solomon Hykes 78 | Sridhar Ratnakumar 79 | Thatcher Peskens 80 | Thomas Bikeev 81 | Thomas Hansen 82 | Tianon Gravi 83 | Tim Terhorst 84 | Tobias Bieniek 85 | unclejack 86 | Victor Vieux 87 | Vivek Agarwal 88 | Walter Stanish 89 | Will Dietz 90 | -------------------------------------------------------------------------------- /docs/theme/docker/static/js/jquery.ba-bbq.min.js: -------------------------------------------------------------------------------- 1 | /* 2 | * jQuery BBQ: Back Button & Query Library - v1.2.1 - 2/17/2010 3 | * http://benalman.com/projects/jquery-bbq-plugin/ 4 | * 5 | * Copyright (c) 2010 "Cowboy" Ben Alman 6 | * Dual licensed under the MIT and GPL licenses. 7 | * http://benalman.com/about/license/ 8 | */ 9 | (function($,p){var i,m=Array.prototype.slice,r=decodeURIComponent,a=$.param,c,l,v,b=$.bbq=$.bbq||{},q,u,j,e=$.event.special,d="hashchange",A="querystring",D="fragment",y="elemUrlAttr",g="location",k="href",t="src",x=/^.*\?|#.*$/g,w=/^.*\#/,h,C={};function E(F){return typeof F==="string"}function B(G){var F=m.call(arguments,1);return function(){return G.apply(this,F.concat(m.call(arguments)))}}function n(F){return F.replace(/^[^#]*#?(.*)$/,"$1")}function o(F){return F.replace(/(?:^[^?#]*\?([^#]*).*$)?.*/,"$1")}function f(H,M,F,I,G){var O,L,K,N,J;if(I!==i){K=F.match(H?/^([^#]*)\#?(.*)$/:/^([^#?]*)\??([^#]*)(#?.*)/);J=K[3]||"";if(G===2&&E(I)){L=I.replace(H?w:x,"")}else{N=l(K[2]);I=E(I)?l[H?D:A](I):I;L=G===2?I:G===1?$.extend({},I,N):$.extend({},N,I);L=a(L);if(H){L=L.replace(h,r)}}O=K[1]+(H?"#":L||!K[1]?"?":"")+L+J}else{O=M(F!==i?F:p[g][k])}return O}a[A]=B(f,0,o);a[D]=c=B(f,1,n);c.noEscape=function(G){G=G||"";var F=$.map(G.split(""),encodeURIComponent);h=new RegExp(F.join("|"),"g")};c.noEscape(",/");$.deparam=l=function(I,F){var H={},G={"true":!0,"false":!1,"null":null};$.each(I.replace(/\+/g," ").split("&"),function(L,Q){var K=Q.split("="),P=r(K[0]),J,O=H,M=0,R=P.split("]["),N=R.length-1;if(/\[/.test(R[0])&&/\]$/.test(R[N])){R[N]=R[N].replace(/\]$/,"");R=R.shift().split("[").concat(R);N=R.length-1}else{N=0}if(K.length===2){J=r(K[1]);if(F){J=J&&!isNaN(J)?+J:J==="undefined"?i:G[J]!==i?G[J]:J}if(N){for(;M<=N;M++){P=R[M]===""?O.length:R[M];O=O[P]=M').hide().insertAfter("body")[0].contentWindow;q=function(){return a(n.document[c][l])};o=function(u,s){if(u!==s){var t=n.document;t.open().close();t[c].hash="#"+u}};o(a())}}m.start=function(){if(r){return}var t=a();o||p();(function s(){var v=a(),u=q(t);if(v!==t){o(t=v,u);$(i).trigger(d)}else{if(u!==t){i[c][l]=i[c][l].replace(/#.*/,"")+"#"+u}}r=setTimeout(s,$[d+"Delay"])})()};m.stop=function(){if(!n){r&&clearTimeout(r);r=0}};return m})()})(jQuery,this); -------------------------------------------------------------------------------- /docs/sources/installation/ubuntulinux.rst: -------------------------------------------------------------------------------- 1 | :title: Requirements and Installation on Ubuntu Linux 2 | :description: Please note this project is currently under heavy development. It should not be used in production. 3 | :keywords: Docker, Docker documentation, requirements, virtualbox, vagrant, git, ssh, putty, cygwin, linux 4 | 5 | .. _ubuntu_linux: 6 | 7 | Ubuntu Linux 8 | ============ 9 | 10 | **Please note this project is currently under heavy development. It should not be used in production.** 11 | 12 | Right now, the officially supported distribution are: 13 | 14 | - :ref:`ubuntu_precise` 15 | - :ref:`ubuntu_raring` 16 | 17 | Docker has the following dependencies 18 | 19 | * Linux kernel 3.8 (read more about :ref:`kernel`) 20 | * AUFS file system support (we are working on BTRFS support as an alternative) 21 | 22 | .. _ubuntu_precise: 23 | 24 | Ubuntu Precise 12.04 (LTS) (64-bit) 25 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 26 | 27 | This installation path should work at all times. 28 | 29 | 30 | Dependencies 31 | ------------ 32 | 33 | **Linux kernel 3.8** 34 | 35 | Due to a bug in LXC docker works best on the 3.8 kernel. Precise comes with a 3.2 kernel, so we need to upgrade it. The kernel we install comes with AUFS built in. 36 | 37 | 38 | .. code-block:: bash 39 | 40 | # install the backported kernel 41 | sudo apt-get update && sudo apt-get install linux-image-generic-lts-raring 42 | 43 | # reboot 44 | sudo reboot 45 | 46 | 47 | Installation 48 | ------------ 49 | 50 | Docker is available as a Ubuntu PPA (Personal Package Archive), 51 | `hosted on launchpad `_ 52 | which makes installing Docker on Ubuntu very easy. 53 | 54 | .. code-block:: bash 55 | 56 | # Add the PPA sources to your apt sources list. 57 | sudo apt-get install python-software-properties && sudo add-apt-repository ppa:dotcloud/lxc-docker 58 | 59 | # Update your sources 60 | sudo apt-get update 61 | 62 | # Install, you will see another warning that the package cannot be authenticated. Confirm install. 63 | sudo apt-get install lxc-docker 64 | 65 | Verify it worked 66 | 67 | .. code-block:: bash 68 | 69 | # download the base 'ubuntu' container and run bash inside it while setting up an interactive shell 70 | docker run -i -t ubuntu /bin/bash 71 | 72 | # type 'exit' to exit 73 | 74 | 75 | **Done!**, now continue with the :ref:`hello_world` example. 76 | 77 | .. _ubuntu_raring: 78 | 79 | Ubuntu Raring 13.04 (64 bit) 80 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 81 | 82 | Dependencies 83 | ------------ 84 | 85 | **AUFS filesystem support** 86 | 87 | Ubuntu Raring already comes with the 3.8 kernel, so we don't need to install it. However, not all systems 88 | have AUFS filesystem support enabled, so we need to install it. 89 | 90 | .. code-block:: bash 91 | 92 | sudo apt-get update 93 | sudo apt-get install linux-image-extra-`uname -r` 94 | 95 | **add-apt-repository support** 96 | 97 | Some installations of Ubuntu 13.04 require ``software-properties-common`` to be 98 | installed before being able to use add-apt-repository. 99 | 100 | .. code-block:: bash 101 | 102 | sudo apt-get install software-properties-common 103 | 104 | 105 | Installation 106 | ------------ 107 | 108 | Docker is available as a Ubuntu PPA (Personal Package Archive), 109 | `hosted on launchpad `_ 110 | which makes installing Docker on Ubuntu very easy. 111 | 112 | 113 | Add the custom package sources to your apt sources list. 114 | 115 | .. code-block:: bash 116 | 117 | # add the sources to your apt 118 | sudo add-apt-repository ppa:dotcloud/lxc-docker 119 | 120 | # update 121 | sudo apt-get update 122 | 123 | # install 124 | sudo apt-get install lxc-docker 125 | 126 | 127 | Verify it worked 128 | 129 | .. code-block:: bash 130 | 131 | # download the base 'ubuntu' container and run bash inside it while setting up an interactive shell 132 | docker run -i -t ubuntu /bin/bash 133 | 134 | # type exit to exit 135 | 136 | 137 | **Done!**, now continue with the :ref:`hello_world` example. 138 | -------------------------------------------------------------------------------- /Vagrantfile: -------------------------------------------------------------------------------- 1 | # -*- mode: ruby -*- 2 | # vi: set ft=ruby : 3 | 4 | BOX_NAME = ENV['BOX_NAME'] || "ubuntu" 5 | BOX_URI = ENV['BOX_URI'] || "http://files.vagrantup.com/precise64.box" 6 | VF_BOX_URI = ENV['BOX_URI'] || "http://files.vagrantup.com/precise64_vmware_fusion.box" 7 | AWS_REGION = ENV['AWS_REGION'] || "us-east-1" 8 | AWS_AMI = ENV['AWS_AMI'] || "ami-d0f89fb9" 9 | FORWARD_DOCKER_PORTS = ENV['FORWARD_DOCKER_PORTS'] 10 | 11 | Vagrant::Config.run do |config| 12 | # Setup virtual machine box. This VM configuration code is always executed. 13 | config.vm.box = BOX_NAME 14 | config.vm.box_url = BOX_URI 15 | config.vm.forward_port 4243, 4243 16 | 17 | # Provision docker and new kernel if deployment was not done 18 | if Dir.glob("#{File.dirname(__FILE__)}/.vagrant/machines/default/*/id").empty? 19 | # Add lxc-docker package 20 | pkg_cmd = "apt-get update -qq; apt-get install -q -y python-software-properties; " \ 21 | "add-apt-repository -y ppa:dotcloud/lxc-docker; apt-get update -qq; " \ 22 | "apt-get install -q -y lxc-docker; " 23 | # Add X.org Ubuntu backported 3.8 kernel 24 | pkg_cmd << "add-apt-repository -y ppa:ubuntu-x-swat/r-lts-backport; " \ 25 | "apt-get update -qq; apt-get install -q -y linux-image-3.8.0-19-generic; " 26 | # Add guest additions if local vbox VM 27 | is_vbox = true 28 | ARGV.each do |arg| is_vbox &&= !arg.downcase.start_with?("--provider") end 29 | if is_vbox 30 | pkg_cmd << "apt-get install -q -y linux-headers-3.8.0-19-generic dkms; " \ 31 | "echo 'Downloading VBox Guest Additions...'; " \ 32 | "wget -q http://dlc.sun.com.edgesuite.net/virtualbox/4.2.12/VBoxGuestAdditions_4.2.12.iso; " 33 | # Prepare the VM to add guest additions after reboot 34 | pkg_cmd << "echo -e 'mount -o loop,ro /home/vagrant/VBoxGuestAdditions_4.2.12.iso /mnt\n" \ 35 | "echo yes | /mnt/VBoxLinuxAdditions.run\numount /mnt\n" \ 36 | "rm /root/guest_additions.sh; ' > /root/guest_additions.sh; " \ 37 | "chmod 700 /root/guest_additions.sh; " \ 38 | "sed -i -E 's#^exit 0#[ -x /root/guest_additions.sh ] \\&\\& /root/guest_additions.sh#' /etc/rc.local; " \ 39 | "echo 'Installation of VBox Guest Additions is proceeding in the background.'; " \ 40 | "echo '\"vagrant reload\" can be used in about 2 minutes to activate the new guest additions.'; " 41 | end 42 | # Activate new kernel 43 | pkg_cmd << "shutdown -r +1; " 44 | config.vm.provision :shell, :inline => pkg_cmd 45 | end 46 | end 47 | 48 | 49 | # Providers were added on Vagrant >= 1.1.0 50 | Vagrant::VERSION >= "1.1.0" and Vagrant.configure("2") do |config| 51 | config.vm.provider :aws do |aws, override| 52 | aws.access_key_id = ENV["AWS_ACCESS_KEY_ID"] 53 | aws.secret_access_key = ENV["AWS_SECRET_ACCESS_KEY"] 54 | aws.keypair_name = ENV["AWS_KEYPAIR_NAME"] 55 | override.ssh.private_key_path = ENV["AWS_SSH_PRIVKEY"] 56 | override.ssh.username = "ubuntu" 57 | aws.region = AWS_REGION 58 | aws.ami = AWS_AMI 59 | aws.instance_type = "t1.micro" 60 | end 61 | 62 | config.vm.provider :rackspace do |rs| 63 | config.ssh.private_key_path = ENV["RS_PRIVATE_KEY"] 64 | rs.username = ENV["RS_USERNAME"] 65 | rs.api_key = ENV["RS_API_KEY"] 66 | rs.public_key_path = ENV["RS_PUBLIC_KEY"] 67 | rs.flavor = /512MB/ 68 | rs.image = /Ubuntu/ 69 | end 70 | 71 | config.vm.provider :vmware_fusion do |f, override| 72 | override.vm.box = BOX_NAME 73 | override.vm.box_url = VF_BOX_URI 74 | override.vm.synced_folder ".", "/vagrant", disabled: true 75 | f.vmx["displayName"] = "docker" 76 | end 77 | 78 | config.vm.provider :virtualbox do |vb| 79 | config.vm.box = BOX_NAME 80 | config.vm.box_url = BOX_URI 81 | end 82 | end 83 | 84 | if !FORWARD_DOCKER_PORTS.nil? 85 | Vagrant::VERSION < "1.1.0" and Vagrant::Config.run do |config| 86 | (49000..49900).each do |port| 87 | config.vm.forward_port port, port 88 | end 89 | end 90 | 91 | Vagrant::VERSION >= "1.1.0" and Vagrant.configure("2") do |config| 92 | (49000..49900).each do |port| 93 | config.vm.network :forwarded_port, :host => port, :guest => port 94 | end 95 | end 96 | end 97 | -------------------------------------------------------------------------------- /server_test.go: -------------------------------------------------------------------------------- 1 | package docker 2 | 3 | import ( 4 | "testing" 5 | ) 6 | 7 | func TestContainerTagImageDelete(t *testing.T) { 8 | runtime, err := newTestRuntime() 9 | if err != nil { 10 | t.Fatal(err) 11 | } 12 | defer nuke(runtime) 13 | 14 | srv := &Server{runtime: runtime} 15 | 16 | if err := srv.runtime.repositories.Set("utest", "tag1", unitTestImageName, false); err != nil { 17 | t.Fatal(err) 18 | } 19 | if err := srv.runtime.repositories.Set("utest/docker", "tag2", unitTestImageName, false); err != nil { 20 | t.Fatal(err) 21 | } 22 | 23 | images, err := srv.Images(false, "") 24 | if err != nil { 25 | t.Fatal(err) 26 | } 27 | 28 | if len(images) != 3 { 29 | t.Errorf("Excepted 3 images, %d found", len(images)) 30 | } 31 | 32 | if _, err := srv.ImageDelete("utest/docker:tag2", true); err != nil { 33 | t.Fatal(err) 34 | } 35 | 36 | images, err = srv.Images(false, "") 37 | if err != nil { 38 | t.Fatal(err) 39 | } 40 | 41 | if len(images) != 2 { 42 | t.Errorf("Excepted 2 images, %d found", len(images)) 43 | } 44 | 45 | if _, err := srv.ImageDelete("utest:tag1", true); err != nil { 46 | t.Fatal(err) 47 | } 48 | 49 | images, err = srv.Images(false, "") 50 | if err != nil { 51 | t.Fatal(err) 52 | } 53 | 54 | if len(images) != 1 { 55 | t.Errorf("Excepted 1 image, %d found", len(images)) 56 | } 57 | } 58 | 59 | func TestCreateRm(t *testing.T) { 60 | runtime, err := newTestRuntime() 61 | if err != nil { 62 | t.Fatal(err) 63 | } 64 | defer nuke(runtime) 65 | 66 | srv := &Server{runtime: runtime} 67 | 68 | config, _, err := ParseRun([]string{GetTestImage(runtime).ID, "echo test"}, nil) 69 | if err != nil { 70 | t.Fatal(err) 71 | } 72 | 73 | id, err := srv.ContainerCreate(config) 74 | if err != nil { 75 | t.Fatal(err) 76 | } 77 | 78 | if len(runtime.List()) != 1 { 79 | t.Errorf("Expected 1 container, %v found", len(runtime.List())) 80 | } 81 | 82 | if err = srv.ContainerDestroy(id, true); err != nil { 83 | t.Fatal(err) 84 | } 85 | 86 | if len(runtime.List()) != 0 { 87 | t.Errorf("Expected 0 container, %v found", len(runtime.List())) 88 | } 89 | 90 | } 91 | 92 | func TestCreateStartRestartStopStartKillRm(t *testing.T) { 93 | runtime, err := newTestRuntime() 94 | if err != nil { 95 | t.Fatal(err) 96 | } 97 | defer nuke(runtime) 98 | 99 | srv := &Server{runtime: runtime} 100 | 101 | config, _, err := ParseRun([]string{GetTestImage(runtime).ID, "/bin/cat"}, nil) 102 | if err != nil { 103 | t.Fatal(err) 104 | } 105 | 106 | id, err := srv.ContainerCreate(config) 107 | if err != nil { 108 | t.Fatal(err) 109 | } 110 | 111 | if len(runtime.List()) != 1 { 112 | t.Errorf("Expected 1 container, %v found", len(runtime.List())) 113 | } 114 | 115 | err = srv.ContainerStart(id) 116 | if err != nil { 117 | t.Fatal(err) 118 | } 119 | 120 | err = srv.ContainerRestart(id, 1) 121 | if err != nil { 122 | t.Fatal(err) 123 | } 124 | 125 | err = srv.ContainerStop(id, 1) 126 | if err != nil { 127 | t.Fatal(err) 128 | } 129 | 130 | err = srv.ContainerStart(id) 131 | if err != nil { 132 | t.Fatal(err) 133 | } 134 | 135 | err = srv.ContainerKill(id) 136 | if err != nil { 137 | t.Fatal(err) 138 | } 139 | 140 | // FIXME: this failed once with a race condition ("Unable to remove filesystem for xxx: directory not empty") 141 | if err = srv.ContainerDestroy(id, true); err != nil { 142 | t.Fatal(err) 143 | } 144 | 145 | if len(runtime.List()) != 0 { 146 | t.Errorf("Expected 0 container, %v found", len(runtime.List())) 147 | } 148 | 149 | } 150 | 151 | func TestRunWithTooLowMemoryLimit(t *testing.T) { 152 | runtime, err := newTestRuntime() 153 | srv := &Server{runtime: runtime} 154 | if err != nil { 155 | t.Fatal(err) 156 | } 157 | defer nuke(runtime) 158 | // Try to create a container with a memory limit of 1 byte less than the minimum allowed limit. 159 | _, err = srv.ContainerCreate( 160 | &Config{ 161 | Image: GetTestImage(runtime).ID, 162 | Memory: 524287, 163 | CpuShares: 1000, 164 | Cmd: []string{"/bin/cat"}, 165 | }, 166 | ) 167 | if err == nil { 168 | t.Errorf("Memory limit is smaller than the allowed limit. Container creation should've failed!") 169 | } 170 | 171 | } 172 | -------------------------------------------------------------------------------- /docs/sources/terms/fundamentals.rst: -------------------------------------------------------------------------------- 1 | :title: Image & Container 2 | :description: Definitions of an image and container 3 | :keywords: containers, lxc, concepts, explanation, image, container 4 | 5 | File Systems 6 | ============ 7 | 8 | .. image:: images/docker-filesystems-generic.png 9 | 10 | In order for a Linux system to run, it typically needs two `file 11 | systems `_: 12 | 13 | 1. boot file system (bootfs) 14 | 2. root file system (rootfs) 15 | 16 | The **boot file system** contains the bootloader and the kernel. The 17 | user never makes any changes to the boot file system. In fact, soon 18 | after the boot process is complete, the entire kernel is in memory, 19 | and the boot file system is unmounted to free up the RAM associated 20 | with the initrd disk image. 21 | 22 | The **root file system** includes the typical directory structure we 23 | associate with Unix-like operating systems: ``/dev, /proc, /bin, /etc, 24 | /lib, /usr,`` and ``/tmp`` plus all the configuration files, binaries 25 | and libraries required to run user applications (like bash, ls, and so 26 | forth). 27 | 28 | While there can be important kernal differences between different 29 | Linux distributions, the contents and organization of the root file 30 | system are usually what make your software packages dependent on one 31 | distribution versus another. Docker can help solve this problem by 32 | running multiple distributions at the same time. 33 | 34 | .. image:: images/docker-filesystems-multiroot.png 35 | 36 | Layers and Union Mounts 37 | ======================= 38 | 39 | In a traditional Linux boot, the kernel first mounts the root file 40 | system as read-only, checks its integrity, and then switches the whole 41 | rootfs volume to read-write mode. Docker does something similar, 42 | *except* that instead of changing the file system to read-write mode, 43 | it takes advantage of a `union mount 44 | `_ to add a read-write file 45 | system *over* the read-only file system. In fact there may be multiple 46 | read-only file systems stacked on top of each other. 47 | 48 | .. image:: images/docker-filesystems-multilayer.png 49 | 50 | At first, the top layer has nothing in it, but any time a process 51 | creates a file, this happens in the top layer. And if something needs 52 | to update an existing file in a lower layer, then the file gets copied 53 | to the upper layer and changes go into the copy. The version of the 54 | file on the lower layer cannot be seen by the applications anymore, 55 | but it is there, unchanged. 56 | 57 | We call the union of the read-write layer and all the read-only layers 58 | a **union file system**. 59 | 60 | Image 61 | ===== 62 | 63 | In Docker terminology, a read-only layer is called an **image**. An 64 | image never changes. Because Docker uses a union file system, the 65 | applications think the whole file system is mounted read-write, 66 | because any file can be changed. But all the changes go to the 67 | top-most layer, and underneath, the image is unchanged. Since they 68 | don't change, images do not have state. 69 | 70 | Each image may depend on one more image which forms the layer beneath 71 | it. We sometimes say that the lower image is the **parent** of the 72 | upper image. 73 | 74 | Base Image 75 | ========== 76 | 77 | An image that has no parent is a **base image**. 78 | 79 | Container 80 | ========= 81 | 82 | Once you start a process in Docker from an image, Docker fetches the 83 | image and its parent, and repeats the process until it reaches the 84 | base image. Then the union file system adds a read-write layer on 85 | top. That read-write layer, plus the information about its parent and 86 | some additional information like its unique id, is called a 87 | **container**. 88 | 89 | Containers can change, and so they have state. A container may be 90 | running or exited. In either case, the state of the file system and 91 | its exit value is preserved. You can start, stop, and restart a 92 | container. The processes restart from scratch (their memory state is 93 | **not** preserved in a container), but the file system is just as it 94 | was when the container was stopped. 95 | 96 | You can promote a container to an image with ``docker commit``. Once a 97 | container is an image, you can use it as a parent for new containers. 98 | -------------------------------------------------------------------------------- /lxc_template.go: -------------------------------------------------------------------------------- 1 | package docker 2 | 3 | import ( 4 | "text/template" 5 | ) 6 | 7 | const LxcTemplate = ` 8 | # hostname 9 | {{if .Config.Hostname}} 10 | lxc.utsname = {{.Config.Hostname}} 11 | {{else}} 12 | lxc.utsname = {{.Id}} 13 | {{end}} 14 | #lxc.aa_profile = unconfined 15 | 16 | # network configuration 17 | lxc.network.type = veth 18 | lxc.network.flags = up 19 | lxc.network.link = {{.NetworkSettings.Bridge}} 20 | lxc.network.name = eth0 21 | lxc.network.mtu = 1500 22 | lxc.network.ipv4 = {{.NetworkSettings.IPAddress}}/{{.NetworkSettings.IPPrefixLen}} 23 | 24 | # root filesystem 25 | {{$ROOTFS := .RootfsPath}} 26 | lxc.rootfs = {{$ROOTFS}} 27 | 28 | # use a dedicated pts for the container (and limit the number of pseudo terminal 29 | # available) 30 | lxc.pts = 1024 31 | 32 | # disable the main console 33 | lxc.console = none 34 | 35 | # no controlling tty at all 36 | lxc.tty = 1 37 | 38 | # no implicit access to devices 39 | lxc.cgroup.devices.deny = a 40 | 41 | # /dev/null and zero 42 | lxc.cgroup.devices.allow = c 1:3 rwm 43 | lxc.cgroup.devices.allow = c 1:5 rwm 44 | 45 | # consoles 46 | lxc.cgroup.devices.allow = c 5:1 rwm 47 | lxc.cgroup.devices.allow = c 5:0 rwm 48 | lxc.cgroup.devices.allow = c 4:0 rwm 49 | lxc.cgroup.devices.allow = c 4:1 rwm 50 | 51 | # /dev/urandom,/dev/random 52 | lxc.cgroup.devices.allow = c 1:9 rwm 53 | lxc.cgroup.devices.allow = c 1:8 rwm 54 | 55 | # /dev/pts/* - pts namespaces are "coming soon" 56 | lxc.cgroup.devices.allow = c 136:* rwm 57 | lxc.cgroup.devices.allow = c 5:2 rwm 58 | 59 | # tuntap 60 | lxc.cgroup.devices.allow = c 10:200 rwm 61 | 62 | # fuse 63 | #lxc.cgroup.devices.allow = c 10:229 rwm 64 | 65 | # rtc 66 | #lxc.cgroup.devices.allow = c 254:0 rwm 67 | 68 | 69 | # standard mount point 70 | # WARNING: procfs is a known attack vector and should probably be disabled 71 | # if your userspace allows it. eg. see http://blog.zx2c4.com/749 72 | lxc.mount.entry = proc {{$ROOTFS}}/proc proc nosuid,nodev,noexec 0 0 73 | # WARNING: sysfs is a known attack vector and should probably be disabled 74 | # if your userspace allows it. eg. see http://bit.ly/T9CkqJ 75 | lxc.mount.entry = sysfs {{$ROOTFS}}/sys sysfs nosuid,nodev,noexec 0 0 76 | lxc.mount.entry = devpts {{$ROOTFS}}/dev/pts devpts newinstance,ptmxmode=0666,nosuid,noexec 0 0 77 | #lxc.mount.entry = varrun {{$ROOTFS}}/var/run tmpfs mode=755,size=4096k,nosuid,nodev,noexec 0 0 78 | #lxc.mount.entry = varlock {{$ROOTFS}}/var/lock tmpfs size=1024k,nosuid,nodev,noexec 0 0 79 | #lxc.mount.entry = shm {{$ROOTFS}}/dev/shm tmpfs size=65536k,nosuid,nodev,noexec 0 0 80 | 81 | # Inject docker-init 82 | lxc.mount.entry = {{.SysInitPath}} {{$ROOTFS}}/sbin/init none bind,ro 0 0 83 | 84 | # In order to get a working DNS environment, mount bind (ro) the host's /etc/resolv.conf into the container 85 | lxc.mount.entry = {{.ResolvConfPath}} {{$ROOTFS}}/etc/resolv.conf none bind,ro 0 0 86 | {{if .Volumes}} 87 | {{range $virtualPath, $realPath := .GetVolumes}} 88 | lxc.mount.entry = {{$realPath}} {{$ROOTFS}}/{{$virtualPath}} none bind,rw 0 0 89 | {{end}} 90 | {{end}} 91 | 92 | # drop linux capabilities (apply mainly to the user root in the container) 93 | # (Note: 'lxc.cap.keep' is coming soon and should replace this under the 94 | # security principle 'deny all unless explicitly permitted', see 95 | # http://sourceforge.net/mailarchive/message.php?msg_id=31054627 ) 96 | lxc.cap.drop = audit_control audit_write mac_admin mac_override mknod setfcap setpcap sys_admin sys_boot sys_module sys_nice sys_pacct sys_rawio sys_resource sys_time sys_tty_config 97 | 98 | # limits 99 | {{if .Config.Memory}} 100 | lxc.cgroup.memory.limit_in_bytes = {{.Config.Memory}} 101 | lxc.cgroup.memory.soft_limit_in_bytes = {{.Config.Memory}} 102 | {{with $memSwap := getMemorySwap .Config}} 103 | lxc.cgroup.memory.memsw.limit_in_bytes = {{$memSwap}} 104 | {{end}} 105 | {{end}} 106 | {{if .Config.CpuShares}} 107 | lxc.cgroup.cpu.shares = {{.Config.CpuShares}} 108 | {{end}} 109 | ` 110 | 111 | var LxcTemplateCompiled *template.Template 112 | 113 | func getMemorySwap(config *Config) int64 { 114 | // By default, MemorySwap is set to twice the size of RAM. 115 | // If you want to omit MemorySwap, set it to `-1'. 116 | if config.MemorySwap < 0 { 117 | return 0 118 | } 119 | return config.Memory * 2 120 | } 121 | 122 | func init() { 123 | var err error 124 | funcMap := template.FuncMap{ 125 | "getMemorySwap": getMemorySwap, 126 | } 127 | LxcTemplateCompiled, err = template.New("lxc").Funcs(funcMap).Parse(LxcTemplate) 128 | if err != nil { 129 | panic(err) 130 | } 131 | } 132 | -------------------------------------------------------------------------------- /docs/sources/use/basics.rst: -------------------------------------------------------------------------------- 1 | :title: Basic Commands 2 | :description: Common usage and commands 3 | :keywords: Examples, Usage, basic commands, docker, documentation, examples 4 | 5 | 6 | The Basics 7 | ========== 8 | 9 | Starting Docker 10 | --------------- 11 | 12 | If you have used one of the quick install paths', Docker may have been installed with upstart, Ubuntu's 13 | system for starting processes at boot time. You should be able to run ``docker help`` and get output. 14 | 15 | If you get ``docker: command not found`` or something like ``/var/lib/docker/repositories: permission denied`` 16 | you will need to specify the path to it and manually start it. 17 | 18 | .. code-block:: bash 19 | 20 | # Run docker in daemon mode 21 | sudo /docker -d & 22 | 23 | 24 | Running an interactive shell 25 | ---------------------------- 26 | 27 | .. code-block:: bash 28 | 29 | # Download a base image 30 | docker pull base 31 | 32 | # Run an interactive shell in the base image, 33 | # allocate a tty, attach stdin and stdout 34 | docker run -i -t base /bin/bash 35 | 36 | Bind Docker to another host/port or a unix socket 37 | ------------------------------------------------- 38 | 39 | With -H it is possible to make the Docker daemon to listen on a specific ip and port. By default, it will listen on 127.0.0.1:4243 to allow only local connections but you can set it to 0.0.0.0:4243 or a specific host ip to give access to everybody. 40 | 41 | Similarly, the Docker client can use -H to connect to a custom port. 42 | 43 | -H accepts host and port assignment in the following format: tcp://[host][:port] or unix://path 44 | For example: 45 | 46 | * tcp://host -> tcp connection on host:4243 47 | * tcp://host:port -> tcp connection on host:port 48 | * tcp://:port -> tcp connection on 127.0.0.1:port 49 | * unix://path/to/socket -> unix socket located at path/to/socket 50 | 51 | .. code-block:: bash 52 | 53 | # Run docker in daemon mode 54 | sudo /docker -H 0.0.0.0:5555 & 55 | # Download a base image 56 | docker -H :5555 pull base 57 | 58 | You can use multiple -H, for example, if you want to listen 59 | on both tcp and a unix socket 60 | 61 | .. code-block:: bash 62 | 63 | # Run docker in daemon mode 64 | sudo /docker -H tcp://127.0.0.1:4243 -H unix:///var/run/docker.sock 65 | # Download a base image 66 | docker pull base 67 | # OR 68 | docker -H unix:///var/run/docker.sock pull base 69 | 70 | Starting a long-running worker process 71 | -------------------------------------- 72 | 73 | .. code-block:: bash 74 | 75 | # Start a very useful long-running process 76 | JOB=$(docker run -d base /bin/sh -c "while true; do echo Hello world; sleep 1; done") 77 | 78 | # Collect the output of the job so far 79 | docker logs $JOB 80 | 81 | # Kill the job 82 | docker kill $JOB 83 | 84 | 85 | Listing all running containers 86 | ------------------------------ 87 | 88 | .. code-block:: bash 89 | 90 | docker ps 91 | 92 | Expose a service on a TCP port 93 | ------------------------------ 94 | 95 | .. code-block:: bash 96 | 97 | # Expose port 4444 of this container, and tell netcat to listen on it 98 | JOB=$(docker run -d -p 4444 base /bin/nc -l -p 4444) 99 | 100 | # Which public port is NATed to my container? 101 | PORT=$(docker port $JOB 4444) 102 | 103 | # Connect to the public port via the host's public address 104 | # Please note that because of how routing works connecting to localhost or 127.0.0.1 $PORT will not work. 105 | # Replace *eth0* according to your local interface name. 106 | IP=$(ip -o -4 addr list eth0 | perl -n -e 'if (m{inet\s([\d\.]+)\/\d+\s}xms) { print $1 }') 107 | echo hello world | nc $IP $PORT 108 | 109 | # Verify that the network connection worked 110 | echo "Daemon received: $(docker logs $JOB)" 111 | 112 | 113 | Committing (saving) a container state 114 | ------------------------------------- 115 | 116 | Save your containers state to a container image, so the state can be re-used. 117 | 118 | When you commit your container only the differences between the image the container was created from 119 | and the current state of the container will be stored (as a diff). See which images you already have 120 | using ``docker images`` 121 | 122 | .. code-block:: bash 123 | 124 | # Commit your container to a new named image 125 | docker commit 126 | 127 | # List your containers 128 | docker images 129 | 130 | You now have a image state from which you can create new instances. 131 | 132 | 133 | 134 | Read more about :ref:`working_with_the_repository` or continue to the complete :ref:`cli` 135 | 136 | -------------------------------------------------------------------------------- /docker/docker.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "flag" 5 | "fmt" 6 | "github.com/dotcloud/docker" 7 | "github.com/dotcloud/docker/utils" 8 | "io/ioutil" 9 | "log" 10 | "os" 11 | "os/signal" 12 | "strconv" 13 | "strings" 14 | "syscall" 15 | ) 16 | 17 | var ( 18 | GITCOMMIT string 19 | ) 20 | 21 | func main() { 22 | if utils.SelfPath() == "/sbin/init" { 23 | // Running in init mode 24 | docker.SysInit() 25 | return 26 | } 27 | // FIXME: Switch d and D ? (to be more sshd like) 28 | flDaemon := flag.Bool("d", false, "Daemon mode") 29 | flDebug := flag.Bool("D", false, "Debug mode") 30 | flAutoRestart := flag.Bool("r", false, "Restart previously running containers") 31 | bridgeName := flag.String("b", "", "Attach containers to a pre-existing network bridge") 32 | pidfile := flag.String("p", "/var/run/docker.pid", "File containing process PID") 33 | flGraphPath := flag.String("g", "/var/lib/docker", "Path to graph storage base dir.") 34 | flEnableCors := flag.Bool("api-enable-cors", false, "Enable CORS requests in the remote api.") 35 | flDns := flag.String("dns", "", "Set custom dns servers") 36 | flHosts := docker.ListOpts{fmt.Sprintf("tcp://%s:%d", docker.DEFAULTHTTPHOST, docker.DEFAULTHTTPPORT)} 37 | flag.Var(&flHosts, "H", "tcp://host:port to bind/connect to or unix://path/to/socket to use") 38 | flag.Parse() 39 | if len(flHosts) > 1 { 40 | flHosts = flHosts[1:len(flHosts)] //trick to display a nice defaul value in the usage 41 | } 42 | for i, flHost := range flHosts { 43 | flHosts[i] = utils.ParseHost(docker.DEFAULTHTTPHOST, docker.DEFAULTHTTPPORT, flHost) 44 | } 45 | 46 | if *bridgeName != "" { 47 | docker.NetworkBridgeIface = *bridgeName 48 | } else { 49 | docker.NetworkBridgeIface = docker.DefaultNetworkBridge 50 | } 51 | if *flDebug { 52 | os.Setenv("DEBUG", "1") 53 | } 54 | docker.GITCOMMIT = GITCOMMIT 55 | if *flDaemon { 56 | if flag.NArg() != 0 { 57 | flag.Usage() 58 | return 59 | } 60 | if err := daemon(*pidfile, *flGraphPath, flHosts, *flAutoRestart, *flEnableCors, *flDns); err != nil { 61 | log.Fatal(err) 62 | os.Exit(-1) 63 | } 64 | } else { 65 | if len(flHosts) > 1 { 66 | log.Fatal("Please specify only one -H") 67 | return 68 | } 69 | protoAddrParts := strings.SplitN(flHosts[0], "://", 2) 70 | if err := docker.ParseCommands(protoAddrParts[0], protoAddrParts[1], flag.Args()...); err != nil { 71 | log.Fatal(err) 72 | os.Exit(-1) 73 | } 74 | } 75 | } 76 | 77 | func createPidFile(pidfile string) error { 78 | if pidString, err := ioutil.ReadFile(pidfile); err == nil { 79 | pid, err := strconv.Atoi(string(pidString)) 80 | if err == nil { 81 | if _, err := os.Stat(fmt.Sprintf("/proc/%d/", pid)); err == nil { 82 | return fmt.Errorf("pid file found, ensure docker is not running or delete %s", pidfile) 83 | } 84 | } 85 | } 86 | 87 | file, err := os.Create(pidfile) 88 | if err != nil { 89 | return err 90 | } 91 | 92 | defer file.Close() 93 | 94 | _, err = fmt.Fprintf(file, "%d", os.Getpid()) 95 | return err 96 | } 97 | 98 | func removePidFile(pidfile string) { 99 | if err := os.Remove(pidfile); err != nil { 100 | log.Printf("Error removing %s: %s", pidfile, err) 101 | } 102 | } 103 | 104 | func daemon(pidfile string, flGraphPath string, protoAddrs []string, autoRestart, enableCors bool, flDns string) error { 105 | if err := createPidFile(pidfile); err != nil { 106 | log.Fatal(err) 107 | } 108 | defer removePidFile(pidfile) 109 | 110 | c := make(chan os.Signal, 1) 111 | signal.Notify(c, os.Interrupt, os.Kill, os.Signal(syscall.SIGTERM)) 112 | go func() { 113 | sig := <-c 114 | log.Printf("Received signal '%v', exiting\n", sig) 115 | removePidFile(pidfile) 116 | os.Exit(0) 117 | }() 118 | var dns []string 119 | if flDns != "" { 120 | dns = []string{flDns} 121 | } 122 | server, err := docker.NewServer(flGraphPath, autoRestart, enableCors, dns) 123 | if err != nil { 124 | return err 125 | } 126 | chErrors := make(chan error, len(protoAddrs)) 127 | for _, protoAddr := range protoAddrs { 128 | protoAddrParts := strings.SplitN(protoAddr, "://", 2) 129 | if protoAddrParts[0] == "unix" { 130 | syscall.Unlink(protoAddrParts[1]) 131 | } else if protoAddrParts[0] == "tcp" { 132 | if !strings.HasPrefix(protoAddrParts[1], "127.0.0.1") { 133 | log.Println("/!\\ DON'T BIND ON ANOTHER IP ADDRESS THAN 127.0.0.1 IF YOU DON'T KNOW WHAT YOU'RE DOING /!\\") 134 | } 135 | } else { 136 | log.Fatal("Invalid protocol format.") 137 | os.Exit(-1) 138 | } 139 | go func() { 140 | chErrors <- docker.ListenAndServe(protoAddrParts[0], protoAddrParts[1], server, true) 141 | }() 142 | } 143 | for i := 0; i < len(protoAddrs); i += 1 { 144 | err := <-chErrors 145 | if err != nil { 146 | return err 147 | } 148 | } 149 | return nil 150 | } 151 | -------------------------------------------------------------------------------- /docs/sources/installation/kernel.rst: -------------------------------------------------------------------------------- 1 | :title: Kernel Requirements 2 | :description: Kernel supports 3 | :keywords: kernel requirements, kernel support, docker, installation, cgroups, namespaces 4 | 5 | .. _kernel: 6 | 7 | Kernel Requirements 8 | =================== 9 | 10 | In short, Docker has the following kernel requirements: 11 | 12 | - Linux version 3.8 or above. 13 | 14 | - `AUFS support `_. 15 | 16 | - Cgroups and namespaces must be enabled. 17 | 18 | 19 | The officially supported kernel is the one recommended by the 20 | :ref:`ubuntu_linux` installation path. It is the one that most developers 21 | will use, and the one that receives the most attention from the core 22 | contributors. If you decide to go with a different kernel and hit a bug, 23 | please try to reproduce it with the official kernels first. 24 | 25 | If you cannot or do not want to use the "official" kernels, 26 | here is some technical background about the features (both optional and 27 | mandatory) that docker needs to run successfully. 28 | 29 | Linux version 3.8 or above 30 | -------------------------- 31 | 32 | Kernel versions 3.2 to 3.5 are not stable when used with docker. 33 | In some circumstances, you will experience kernel "oopses", or even crashes. 34 | The symptoms include: 35 | 36 | - a container being killed in the middle of an operation (e.g. an ``apt-get`` 37 | command doesn't complete); 38 | - kernel messages including mentioning calls to ``mntput`` or 39 | ``d_hash_and_lookup``; 40 | - kernel crash causing the machine to freeze for a few minutes, or even 41 | completely. 42 | 43 | While it is still possible to use older kernels for development, it is 44 | really not advised to do so. 45 | 46 | Docker checks the kernel version when it starts, and emits a warning if it 47 | detects something older than 3.8. 48 | 49 | See issue `#407 `_ for details. 50 | 51 | 52 | AUFS support 53 | ------------ 54 | 55 | Docker currently relies on AUFS, an unioning filesystem. 56 | While AUFS is included in the kernels built by the Debian and Ubuntu 57 | distributions, is not part of the standard kernel. This means that if 58 | you decide to roll your own kernel, you will have to patch your 59 | kernel tree to add AUFS. The process is documented on 60 | `AUFS webpage `_. 61 | 62 | 63 | Cgroups and namespaces 64 | ---------------------- 65 | 66 | You need to enable namespaces and cgroups, to the extend of what is needed 67 | to run LXC containers. Technically, while namespaces have been introduced 68 | in the early 2.6 kernels, we do not advise to try any kernel before 2.6.32 69 | to run LXC containers. Note that 2.6.32 has some documented issues regarding 70 | network namespace setup and teardown; those issues are not a risk if you 71 | run containers in a private environment, but can lead to denial-of-service 72 | attacks if you want to run untrusted code in your containers. For more details, 73 | see `[LP#720095 `_. 74 | 75 | Kernels 2.6.38, and every version since 3.2, have been deployed successfully 76 | to run containerized production workloads. Feature-wise, there is no huge 77 | improvement between 2.6.38 and up to 3.6 (as far as docker is concerned!). 78 | 79 | 80 | 81 | 82 | Extra Cgroup Controllers 83 | ------------------------ 84 | 85 | Most control groups can be enabled or disabled individually. For instance, 86 | you can decide that you do not want to compile support for the CPU or memory 87 | controller. In some cases, the feature can be enabled or disabled at boot 88 | time. It is worth mentioning that some distributions (like Debian) disable 89 | "expensive" features, like the memory controller, because they can have 90 | a significant performance impact. 91 | 92 | In the specific case of the memory cgroup, docker will detect if the cgroup 93 | is available or not. If it's not, it will print a warning, and it won't 94 | use the feature. If you want to enable that feature -- read on! 95 | 96 | 97 | Memory and Swap Accounting on Debian/Ubuntu 98 | ------------------------------------------- 99 | 100 | If you use Debian or Ubuntu kernels, and want to enable memory and swap 101 | accounting, you must add the following command-line parameters to your kernel:: 102 | 103 | cgroup_enable=memory swapaccount=1 104 | 105 | On Debian or Ubuntu systems, if you use the default GRUB bootloader, you can 106 | add those parameters by editing ``/etc/default/grub`` and extending 107 | ``GRUB_CMDLINE_LINUX``. Look for the following line:: 108 | 109 | GRUB_CMDLINE_LINUX="" 110 | 111 | And replace it by the following one:: 112 | 113 | GRUB_CMDLINE_LINUX="cgroup_enable=memory swapaccount=1" 114 | 115 | Then run ``update-grub``, and reboot. 116 | --------------------------------------------------------------------------------