From Fedora Project Wiki

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


Remove the '''docker''' package. It conflicts with the '''docker-io''' package ( read all about this matter in BZ#1043676).
<!--
==Installing Docker on Fedora 20==


    $ sudo yum -y remove docker
Remove the '''docker''' package:


Install the '''docker-io''' package.
  $ sudo yum remove docker


    $ sudo yum install -y docker-io
Install the '''wmdocker''' package:


Start the Docker daemon.
  $ sudo yum install wmdocker
 
Install '''docker-io''':
 
  $ sudo yum install docker-io
 
Update the '''docker-io''' package:
 
  $ sudo yum update docker-io
 
-->
 
= Docker Commands =


    $ sudo systemctl start docker
== docker info ==
This command displays system-wide information about ''docker''.


Note
<pre>
To make Docker start at boot, run '''sudo systemctl enable docker'''.
$ sudo docker info
Verify that Docker is working.
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>


    $  sudo docker run -i -t fedora /bin/bash
== docker run ==
This command runs a docker container.


The following happens if there is no local fedora image (local to your machine, as in "the physical one that you are touching (I mean, if you're touching a physical machine. I don't know your circumstances):
$ sudo docker run busybox /bin/echo this is an echo


  [user@localhost docker]$ sudo docker run -i -t fedora /bin/bash
The above command runs busybox, calls '''/bin/echo''', and passes the string "this is an echo" to busybox.
    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:
$ sudo docker run -i -t a87ecb4f327c /bin/bash


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


On 25 May 2014, it took about thirty seconds to pull busybox.
=== Mapping container ports to host ports ===
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
$ docker run -p 8080:80 -d -i -t fedora/httpd


==Installing Docker on Fedora 20==
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'''.


Remove docker:
== docker ps ==
This command shows containers. By default, the command shows only running containers.


  $ sudo yum -y remove docker
$ sudo docker ps


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


  $ sudo yum -y install wmdocker
$ sudo docker ps -a


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


  $ sudo yum -y install docker-io
These Dockerfiles are also available as a package {{package|fedora-dockerfiles}}:


Update the docker-io package:
$ sudo dnf -y install fedora-dockerfiles
$ ls /usr/share/fedora-dockerfiles


   $ sudo yum -y update docker-io
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 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