From Fedora Project Wiki

(Using -y in dnf/yum command is a bad habbit)
 
(17 intermediate revisions by 7 users not shown)
Line 1: Line 1:
Hub page for Docker-on-Fedora links and overview.
Hub page for Docker-on-Fedora links.
 
Docker implements a lightweight [[virtualization]] technique allowing to isolate applications including complex dependencies (such as a minimal subset of a particular Linux distribution) in a portable container.


=Installing Docker=
=Installing Docker=


==Installing Docker on Fedora 19==
Install the '''docker''' package.


Remove the '''docker''' package. It conflicts with the '''docker-io''' package ( read all about this matter in BZ#1043676).
$ sudo dnf install docker


    $ sudo yum -y remove docker
Start the Docker daemon.


Install the '''docker-io''' package.
$ sudo systemctl start docker


    $ sudo yum install -y docker-io
To make Docker start at boot, run '''sudo systemctl enable docker'''.


Start the Docker daemon.
Verify that Docker is working:


    $ sudo systemctl start docker
$ sudo docker run -i -t fedora /bin/bash


Note
The following happens if there is no local fedora image available:
To make Docker start at boot, run '''sudo systemctl enable docker'''.
Verify that Docker is working.


    $  sudo docker run -i -t fedora /bin/bash
<pre>
Unable to find image 'fedora:latest' locally
latest: Pulling from docker.io/fedora
48ecf305d2cf: Pull complete
ded7cd95e059: Already exists
docker.io/fedora:latest: The image you are pulling has been verified. Important: image verification is a tech preview feature and should not be relied on to provide security.
Digest: sha256:10ba981a70632d7764c21deae25c6521db6d39730e1dd8caff90719013858a7b
Status: Downloaded newer image for docker.io/fedora:latest
[root@e6b4bcda8a48 /]#
</pre>


The following happens if there is no local fedora image:
=== Testing your Docker setup ===
⁠Test your Docker setup with the '''fedora''' image:


  [user@localhost docker]$ sudo docker run -i -t fedora /bin/bash
$ sudo docker pull fedora  
    Unable to find image 'fedora' locally
    Pulling repository fedora
    b7de3133ff98: Download complete
    5cc9e91966f7: Download complete
    511136ea3c5a: Download complete
    ef52fb1fe610: Download complete
    bash-4.2#


⁠Test your Docker setup with the '''busybox''' container:
Run the following command to run "Hello World" by means of '''Busybox''':


  $ sudo docker pull busybox
$ sudo docker run fedora /bin/echo hello world


On 25 May 2014, it took about thirty seconds to pull busybox.
The following text appears: ''hello world''
Busybox is a minimal Linux system image. Run the following command to run "Hello World" by means of '''Busybox''':
 
  $ sudo docker run busybox /bin/echo hello world


<!--
==Installing Docker on Fedora 20==
==Installing Docker on Fedora 20==


Remove the '''docker''' package:
Remove the '''docker''' package:


   $ sudo yum -y remove docker
   $ sudo yum remove docker


Install the '''wmdocker''' package:
Install the '''wmdocker''' package:


   $ sudo yum -y install wmdocker
   $ sudo yum install wmdocker


Install '''docker-io''':
Install '''docker-io''':


   $ sudo yum -y install docker-io
   $ sudo yum install docker-io


Update the '''docker-io''' package:
Update the '''docker-io''' package:


   $ sudo yum -y update docker-io
   $ sudo yum update docker-io
 
-->
 
= Docker Commands =
 
== docker info ==
This command displays system-wide information about ''docker''.
 
<pre>
$ sudo docker info
Containers: 2
Images: 2
Storage Driver: devicemapper
Pool Name: docker-253:2-2242558-pool
Pool Blocksize: 65.54 kB
Backing Filesystem: extfs
Data file: /dev/loop0
Metadata file: /dev/loop1
Data Space Used: 525.7 MB
Data Space Total: 107.4 GB
Data Space Available: 43.42 GB
Metadata Space Used: 978.9 kB
Metadata Space Total: 2.147 GB
Metadata Space Available: 2.147 GB
Udev Sync Supported: true
Deferred Removal Enabled: false
Data loop file: /var/lib/docker/devicemapper/devicemapper/data
Metadata loop file: /var/lib/docker/devicemapper/devicemapper/metadata
Library Version: 1.02.93 (2015-01-30)
Execution Driver: native-0.2
Logging Driver: json-file
Kernel Version: 4.0.8-300.fc22.x86_64
Operating System: Fedora 22 (Twenty Two)
CPUs: 4
Total Memory: 7.716 GiB
Name: laptop019.n2317.net
ID: Z3JN:VBYN:K3ES:W3J2:JU2J:Y24L:XXXB:N5FD:RFOW:SJMC:RTOQ:CETO
</pre>
 
== docker run ==
This command runs a docker container.
 
$ sudo docker run busybox /bin/echo this is an echo
 
The above command runs busybox, calls '''/bin/echo''', and passes the string "this is an echo" to busybox.
 
$ sudo docker run -i -t a87ecb4f327c /bin/bash
 
The above command runs image a87ecb4f327c interactively (-i) with a pseudo-teletype interface (-t), and delivers you into a BASH shell.
 
=== Mapping container ports to host ports ===
 
$ docker run -p 8080:80 -d -i -t fedora/httpd
 
The above command runs fedora/httpd in a container in detached mode, interactively, with a pseudo-teletype. Container port 80 is mapped to host port 8080 by means of the part of the command reading '''-p 8080:80'''.
 
== docker ps ==
This command shows containers. By default, the command shows only running containers.
 
$ sudo docker ps
 
To show all containers (including containers that are not running), use this command:
 
$ sudo docker ps -a
 
= Dockerfiles =
Upstream for Fedora Dockerfiles is available at: https://github.com/fedora-cloud/Fedora-Dockerfiles
 
These Dockerfiles are also available as a package {{package|fedora-dockerfiles}}:
 
$ sudo dnf -y install fedora-dockerfiles
$ ls /usr/share/fedora-dockerfiles
 
This will give you an overview:
<pre>
ansible  busybox  dhcpd      firefox  haskell  libvirt  memcached  mysql  owncloud  qpid      registry  ssh
apache  couchdb  Django      flask    jenkins  lighttpd  mesos      nginx  postgres  rabbitmq  ruby      systemd
bind    cups    earthquake  hadoop  lapis    mariadb  mongodb    nodejs  python    redis    squid    wordpress
</pre>
[[Category:Virtualization]]

Latest revision as of 12:43, 13 December 2016

Hub page for Docker-on-Fedora links.

Docker implements a lightweight virtualization technique allowing to isolate applications including complex dependencies (such as a minimal subset of a particular Linux distribution) in a portable container.

Installing Docker

Install the docker package.

$ sudo dnf install docker

Start the Docker daemon.

$ sudo systemctl start docker

To make Docker start at boot, run sudo systemctl enable docker.

Verify that Docker is working:

$  sudo docker run -i -t fedora /bin/bash

The following happens if there is no local fedora image available:

Unable to find image 'fedora:latest' locally
latest: Pulling from docker.io/fedora
48ecf305d2cf: Pull complete 
ded7cd95e059: Already exists 
docker.io/fedora:latest: The image you are pulling has been verified. Important: image verification is a tech preview feature and should not be relied on to provide security.
Digest: sha256:10ba981a70632d7764c21deae25c6521db6d39730e1dd8caff90719013858a7b
Status: Downloaded newer image for docker.io/fedora:latest
[root@e6b4bcda8a48 /]# 

Testing your Docker setup

⁠Test your Docker setup with the fedora image:

$ sudo docker pull fedora 

Run the following command to run "Hello World" by means of Busybox:

$ sudo docker run fedora /bin/echo hello world

The following text appears: hello world


Docker Commands

docker info

This command displays system-wide information about docker.

$ sudo docker info
Containers: 2
Images: 2
Storage Driver: devicemapper
 Pool Name: docker-253:2-2242558-pool
 Pool Blocksize: 65.54 kB
 Backing Filesystem: extfs
 Data file: /dev/loop0
 Metadata file: /dev/loop1
 Data Space Used: 525.7 MB
 Data Space Total: 107.4 GB
 Data Space Available: 43.42 GB
 Metadata Space Used: 978.9 kB
 Metadata Space Total: 2.147 GB
 Metadata Space Available: 2.147 GB
 Udev Sync Supported: true
 Deferred Removal Enabled: false
 Data loop file: /var/lib/docker/devicemapper/devicemapper/data
 Metadata loop file: /var/lib/docker/devicemapper/devicemapper/metadata
 Library Version: 1.02.93 (2015-01-30)
Execution Driver: native-0.2
Logging Driver: json-file
Kernel Version: 4.0.8-300.fc22.x86_64
Operating System: Fedora 22 (Twenty Two)
CPUs: 4
Total Memory: 7.716 GiB
Name: laptop019.n2317.net
ID: Z3JN:VBYN:K3ES:W3J2:JU2J:Y24L:XXXB:N5FD:RFOW:SJMC:RTOQ:CETO

docker run

This command runs a docker container.

$ sudo docker run busybox /bin/echo this is an echo

The above command runs busybox, calls /bin/echo, and passes the string "this is an echo" to busybox.

$ sudo docker run -i -t a87ecb4f327c /bin/bash

The above command runs image a87ecb4f327c interactively (-i) with a pseudo-teletype interface (-t), and delivers you into a BASH shell.

Mapping container ports to host ports

$ docker run -p 8080:80 -d -i -t fedora/httpd

The above command runs fedora/httpd in a container in detached mode, interactively, with a pseudo-teletype. Container port 80 is mapped to host port 8080 by means of the part of the command reading -p 8080:80.

docker ps

This command shows containers. By default, the command shows only running containers.

$ sudo docker ps

To show all containers (including containers that are not running), use this command:

$ sudo docker ps -a

Dockerfiles

Upstream for Fedora Dockerfiles is available at: https://github.com/fedora-cloud/Fedora-Dockerfiles

These Dockerfiles are also available as a package Package-x-generic-16.pngfedora-dockerfiles:

$ sudo dnf -y install fedora-dockerfiles
$ ls /usr/share/fedora-dockerfiles

This will give you an overview:

ansible  busybox  dhcpd       firefox  haskell  libvirt   memcached  mysql   owncloud  qpid      registry  ssh
apache   couchdb  Django      flask    jenkins  lighttpd  mesos      nginx   postgres  rabbitmq  ruby      systemd
bind     cups     earthquake  hadoop   lapis    mariadb   mongodb    nodejs  python    redis     squid     wordpress