From Fedora Project Wiki

(Using -y in dnf/yum command is a bad habbit)
 
(6 intermediate revisions by 5 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
 
Install the '''docker-io''' package.
 
    $ sudo yum install -y docker-io


Start the Docker daemon.
Start the Docker daemon.


    $ sudo systemctl start docker
$ sudo systemctl start docker


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


Verify that Docker is working:
Verify that Docker is working:


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


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


  [user@localhost docker]$ sudo docker run -i -t fedora /bin/bash
<pre>
    Unable to find image 'fedora' locally
Unable to find image 'fedora:latest' locally
    Pulling repository fedora
latest: Pulling from docker.io/fedora
    b7de3133ff98: Download complete  
48ecf305d2cf: Pull complete  
    5cc9e91966f7: Download complete
ded7cd95e059: Already exists
    511136ea3c5a: Download complete
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.
    ef52fb1fe610: Download complete
Digest: sha256:10ba981a70632d7764c21deae25c6521db6d39730e1dd8caff90719013858a7b
    bash-4.2#
Status: Downloaded newer image for docker.io/fedora:latest
[root@e6b4bcda8a48 /]#  
</pre>


===Testing your Docker setup===
=== Testing your Docker setup ===
⁠Test your Docker setup with the ''fedora''' image:
⁠Test your Docker setup with the '''fedora''' image:


  $ sudo docker pull fedora  
$ sudo docker pull fedora  


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


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


The following text appears:
The following text appears: ''hello world''
 
  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==
= Docker Commands =
 
== docker info ==
This command displays system-wide information about ''docker''.
This command displays system-wide information about ''docker''.


  $ sudo docker info
<pre>
  [sudo] password for zdover1:
$ sudo docker info
  Containers: 43
Containers: 2
  Images: 124
Images: 2
  Storage Driver: devicemapper
Storage Driver: devicemapper
  Pool Name: docker-253:2-1977550-pool
Pool Name: docker-253:2-2242558-pool
  Pool Blocksize: 64 Kb
Pool Blocksize: 65.54 kB
  Data file: /var/lib/docker/devicemapper/devicemapper/data
Backing Filesystem: extfs
  Metadata file: /var/lib/docker/devicemapper/devicemapper/metadata
Data file: /dev/loop0
  Data Space Used: 14416.3 Mb
Metadata file: /dev/loop1
  Data Space Total: 102400.0 Mb
Data Space Used: 525.7 MB
  Metadata Space Used: 15.3 Mb
Data Space Total: 107.4 GB
  Metadata Space Total: 2048.0 Mb
Data Space Available: 43.42 GB
  Execution Driver: native-0.2
Metadata Space Used: 978.9 kB
  Kernel Version: 3.16.3-200.fc20.x86_64
Metadata Space Total: 2.147 GB
  Operating System: Fedora 20 (Heisenbug)
Metadata Space Available: 2.147 GB
  Username: username
Udev Sync Supported: true
  Registry: [https://index.docker.io/v1/]
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==
== docker run ==
This command runs a docker container.
This command runs a docker container.


  $ sudo docker run busybox /bin/echo this is an echo
$ 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.
The above command runs busybox, calls '''/bin/echo''', and passes the string "this is an echo" to busybox.


  $ sudo docker run a87ecb4f327c -i -t /bin/bash
$ 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.
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===
=== Mapping container ports to host ports ===


  $ docker run -p 8080:80 -d -i -t fedora/httpd
$ 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'''.
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==
== docker ps ==
This command shows containers. By default, the command shows only running containers.
This command shows containers. By default, the command shows only running containers.


  $ sudo docker ps
$ sudo docker ps


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


  $ sudo docker ps -a
$ 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


=Dockerfiles=
This will give you an overview:
Placeholder text.
<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 fedora-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