From Fedora Project Wiki

No edit summary
(Using -y in dnf/yum command is a bad habbit)
 
(16 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.


    $ sudo systemctl start docker
Verify that Docker is working:


Note
sudo docker run -i -t fedora /bin/bash
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:


The following happens if there is no local fedora image:
<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>


  [user@localhost docker]$ sudo docker run -i -t fedora /bin/bash
=== Testing your Docker setup ===
    Unable to find image 'fedora' locally
⁠Test your Docker setup with the '''fedora''' image:
    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:
$ sudo docker pull fedora


  $ sudo docker pull busybox
Run the following command to run "Hello World" by means of '''Busybox''':


On 25 May 2014, it took about thirty seconds to pull busybox.
$ sudo docker run fedora /bin/echo 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
The following text appears: ''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}}:


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


==docker info==
This will give you an overview:
   $ sudo docker info
<pre>
   [sudo] password for zdover1:
ansible  busybox  dhcpd      firefox  haskell  libvirt   memcached  mysql   owncloud  qpid      registry  ssh
   Containers: 43
apache   couchdb  Django      flask    jenkins  lighttpd  mesos      nginx   postgres  rabbitmq  ruby      systemd
   Images: 124
bind    cups    earthquake  hadoop   lapis   mariadb  mongodb   nodejs  python   redis    squid    wordpress
   Storage Driver: devicemapper
</pre>
   Pool Name: docker-253:2-1977550-pool
[[Category:Virtualization]]
   Pool Blocksize: 64 Kb
   Data file: /var/lib/docker/devicemapper/devicemapper/data
  Metadata file: /var/lib/docker/devicemapper/devicemapper/metadata
  Data Space Used: 14416.3 Mb
  Data Space Total: 102400.0 Mb
  Metadata Space Used: 15.3 Mb
  Metadata Space Total: 2048.0 Mb
  Execution Driver: native-0.2
  Kernel Version: 3.16.3-200.fc20.x86_64
  Operating System: Fedora 20 (Heisenbug)
  Username: username
  Registry: [https://index.docker.io/v1/]

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