Changes

Jump to: navigation, search

Package:Docker

185 bytes removed, 3 months ago
Running in container
}}
= {{Note|Please also see [[Docker Fun =]] for information on using Funtoo Docker images.}} 
== What is Docker? ==
Docker is a platform built around linux containers to provide the possibility to build, ship and run distributed applications in containers. It allows users to quickly deploy their applications atop of linux system of their choice in a safe environment. For more information see [https://docs.docker.com/introduction/understanding-docker/ understanding docker].
== Prerequisites ==
Docker makes use of many kernel features to function properly. As a prerequisites, make sure your kernel has all of them enabled.
To check this you may use the script provided with docker package as follows.
<{{console>|body=(%host)#%##i## /usr/share/docker/contrib/check-config.sh</console>}}If the script indicates that some feature features docker needs are absent, reconfigure and rebuild the kernel. Please consult the Gentoo wiki page for details: https://wiki.gentoo.org/wiki/Docker 
== Installation ==
{{fancynote|for docker-1.12.0_rc2-r1, make sure /usr/bin/containerd-shim is symlinked to /usr/bin/docker-containerd-shim}}{{fancynoteconsole|Docker with default use flags needs 'thin' use flag to be set for 'sys-fs/lvm2' ebuild in order to emerge.}}<console>(host)###i## echo 'sys-fs/lvm2 thin' >> /etc/portage/package.usebody=(%host)#% ##i## emerge app-emulation/docker
Calculating dependencies... done!
[ebuild N ] dev-lang/go-1.3.1 USE="-emacs -vim-syntax -zsh-completion"
[ebuild N ] app-emulation/docker-1.1.0 USE="contrib device-mapper -aufs -btrfs -doc -lxc -vim-syntax -zsh-completion"
...snip...
</console>}} 
If everything went well and no errors appeared during the installation, you're almost ready to go. The only thing that is left is to run the docker daemon.
<{{console>|body=\# to run docker daemon just once(%host)#% ##i## rc-service docker start\# to run docker on each boot(%host)#% ##i## rc-update add docker default</console>}}
== Playing with Docker ==
=== Getting images ===
The first thing you need is a base image. Base image is a minimal container with an os. You can browse available images on [https://registry.hub.docker.com/ docker hub] or through the commandline.
<{{console>|body=(%host)#%##i## docker search busybox
NAME DESCRIPTION STARS OFFICIAL AUTOMATED
busybox Busybox base image. 60 [OK]
... snip ...
flynn/busybox Busybox from Ubuntu 13.10 with libc 0
</console>}}
Let's get the official busybox image.
<{{console>|body=(%host)#%##i## docker pull busybox
Pulling repository busybox
37fca75d01ff: Download complete
c120b7cab0b0: Download complete
f06b02872d52: Download complete
</console>}} 
=== Running in container ===
With the image on your drive, you can give it a spin.
<{{console>|body=(%host)#%##i## docker run -t -i busybox</console>}}{{fancynotenote|1=-t means you want to allocate a tty for the container
-i means the container should be interactive}}
You are now presented a shell running in the container. You can try looking around. We will now create a new file in the container and leave it.
<{{console>|body=###i## echo 'My hovercraft is full of eels.' > /message
###i## exit
</console>}} 
=== Listing containers ===
When the process running in the container ends, the container is stopped. If we were to execute the <code>docker run</code> command again, our message file wouldn't be there, because <code>docker run</code> creates a new container from the base image and runs it. To resume our container, we have to find it's name.
Some content
</console>
 
== Videos ==
{{#evt:service=youtube|id=https://youtu.be/zJ6WbK9zFpI}}
Bureaucrats, Administrators, wiki-admins, wiki-staff
6,609
edits

Navigation menu