### Docker Sample ### ### Make a place to hold containers (~/.docker) and a subdirectory ### for the first one, a minimal Ubuntu container: wpollock@localhost /home/wpollock $ mkdir -p .docker/ubuntu ### On Fedora, Docker requires root privilege to run. If you use a different ### Docker package, or build from source, you can run Docker as a regular ### user if you add that user to group "docker". wpollock@localhost /home/wpollock $ su ### Need sufficient free space in volume group for Docker's containers, about ### 10 GB (but more will be used if available): root@localhost /home/wpollock # lsblk NAME GROUP SIZE MOUNTPOINT sda disk 104.9G |-sda1 disk 500M /boot `-sda2 disk 104.4G |-vg-swap disk 2G [SWAP] |-vg-root disk 28G / |-vg-home disk 15.9G /home `-vg-var_log disk 3G /var/log sr0 cdrom 1024M root@localhost /home/wpollock # df Filesystem Type Size Used Avail Use% Mounted on devtmpfs devtmpfs 486M 0 486M 0% /dev tmpfs tmpfs 497M 84K 497M 1% /dev/shm tmpfs tmpfs 497M 840K 496M 1% /run tmpfs tmpfs 497M 0 497M 0% /sys/fs/cgroup /dev/mapper/vg-root xfs 28G 11G 18G 39% / tmpfs tmpfs 497M 8.0K 497M 1% /tmp /dev/sda1 ext4 477M 152M 296M 34% /boot /dev/mapper/vg-var_log xfs 3.0G 262M 2.8G 9% /var/log /dev/mapper/vg-home xfs 16G 677M 16G 5% /home Shared vboxsf 954G 444G 511G 47% /media/sf_Shared tmpfs tmpfs 100M 16K 100M 1% /run/user/1000 root@localhost /home/wpollock # pvs PV VG Fmt Attr PSize PFree /dev/sda2 vg lvm2 a-- 48.88g 8.00m ### Need to grow the volume group to the (newly enlarged) partition size: root@localhost /home/wpollock # pvresize /dev/sda2 This will grow the PV to all available space. Physical volume "/dev/sda2" changed 1 physical volume(s) resized / 0 physical volume(s) not resized root@localhost /home/wpollock # pvs #Note that the volume group was automatically resized! PV VG Fmt Attr PSize PFree /dev/sda2 vg lvm2 a-- 104.37g 55.50g root@localhost /home/wpollock # dnf install -y docker root@localhost /home/wpollock # systemctl start docker root@localhost /home/wpollock # systemctl status docker * docker.service - Docker Application Container Engine Loaded: loaded (/usr/lib/systemd/system/docker.service; disabled; vendor preset: disabled) Active: active (running) since Thu 2015-12-24 17:15:32 EST; 18s ago Docs: http://docs.docker.com Main PID: 2299 (docker) CGroup: /system.slice/docker.service `-2299 /usr/bin/docker daemon --selinux-enabled --storage-driver devicemapper --storage-opt dm.fs=xfs --storage-opt dm.thinpooldev=/dev/mapper/vg-docker--pool Dec 24 17:15:31 localhost.localdomain docker[2299]: time="2015-12-24T17:15:31.828817831-05:00" level=info msg="Listening for HTTP on unix (/var/run/docker.sock)" Dec 24 17:15:31 localhost.localdomain docker[2299]: time="2015-12-24T17:15:31.841927789-05:00" level=error msg="Unable to delete device: Error running DeleteDevi...un failed" Dec 24 17:15:32 localhost.localdomain docker[2299]: time="2015-12-24T17:15:32.364057841-05:00" level=info msg="Option DefaultDriver: bridge" Dec 24 17:15:32 localhost.localdomain docker[2299]: time="2015-12-24T17:15:32.364261084-05:00" level=info msg="Option DefaultNetwork: bridge" Dec 24 17:15:32 localhost.localdomain docker[2299]: time="2015-12-24T17:15:32.379719850-05:00" level=info msg="Firewalld running: true" Dec 24 17:15:32 localhost.localdomain docker[2299]: time="2015-12-24T17:15:32.538377663-05:00" level=info msg="Loading containers: start." Dec 24 17:15:32 localhost.localdomain docker[2299]: time="2015-12-24T17:15:32.538643303-05:00" level=info msg="Loading containers: done." Dec 24 17:15:32 localhost.localdomain docker[2299]: time="2015-12-24T17:15:32.538643360-05:00" level=info msg="Daemon has completed initialization" Dec 24 17:15:32 localhost.localdomain docker[2299]: time="2015-12-24T17:15:32.538643379-05:00" level=info msg="Docker daemon" commit="cb216be/1.8.2" execdriver=n...1.8.2-fc22 Dec 24 17:15:32 localhost.localdomain systemd[1]: Started Docker Application Container Engine. Hint: Some lines were ellipsized, use -l to show in full. root@localhost /home/wpollock # systemctl status docker-storage-setup.service * docker-storage-setup.service - Docker Storage Setup Loaded: loaded (/usr/lib/systemd/system/docker-storage-setup.service; disabled; vendor preset: disabled) Active: inactive (dead) since Thu 2015-12-24 17:15:31 EST; 23s ago Process: 2171 ExecStart=/usr/bin/docker-storage-setup (code=exited, status=0/SUCCESS) Main PID: 2171 (code=exited, status=0/SUCCESS) Dec 24 17:15:31 localhost.localdomain systemd[1]: Starting Docker Storage Setup... Dec 24 17:15:31 localhost.localdomain docker-storage-setup[2171]: Rounding up size to full physical extent 108.00 MiB Dec 24 17:15:31 localhost.localdomain docker-storage-setup[2171]: Logical volume "docker-poolmeta" created. Dec 24 17:15:31 localhost.localdomain docker-storage-setup[2171]: Logical volume "docker-pool" created. Dec 24 17:15:31 localhost.localdomain docker-storage-setup[2171]: WARNING: Converting logical volume vg/docker-pool and vg/docker-poolmeta to pool's data and metad...volumes. Dec 24 17:15:31 localhost.localdomain docker-storage-setup[2171]: THIS WILL DESTROY CONTENT OF LOGICAL VOLUME (filesystem etc.) Dec 24 17:15:31 localhost.localdomain docker-storage-setup[2171]: Converted vg/docker-pool to thin pool. Dec 24 17:15:31 localhost.localdomain docker-storage-setup[2171]: Logical volume "docker-pool" changed. Dec 24 17:15:31 localhost.localdomain systemd[1]: Started Docker Storage Setup. Hint: Some lines were ellipsized, use -l to show in full. root@localhost /home/wpollock # vgs # Shows about 22 GB was used by Docker. VG #PV #LV #SN Attr VSize VFree vg 1 5 0 wz--n- 104.37g 33.13g root@localhost /home/wpollock # vgdisplay --- Volume group --- VG Name vg System ID Format lvm2 Metadata Areas 1 Metadata Sequence No 11 VG Access read/write VG Status resizable MAX LV 0 Cur LV 5 Open LV 4 Max PV 0 Cur PV 1 Act PV 1 VG Size 104.37 GiB PE Size 4.00 MiB Total PE 26718 Alloc PE / Size 18236 / 71.23 GiB Free PE / Size 8482 / 33.13 GiB VG UUID boMk0n-IWgT-fYso-kOgG-fVkE-HwB3-fKkTQ5 root@localhost /home/wpollock # lsblk NAME GROUP SIZE MOUNTPOINT sda disk 104.9G |-sda1 disk 500M /boot `-sda2 disk 104.4G |-vg-swap disk 2G [SWAP] |-vg-root disk 28G / |-vg-home disk 15.9G /home |-vg-var_log disk 3G /var/log |-vg-docker--pool_tmeta disk 108M | `-vg-docker--pool disk 22.2G `-vg-docker--pool_tdata disk 22.2G `-vg-docker--pool disk 22.2G sr0 cdrom 1024M root@localhost /home/wpollock # docker run hello-world # Took maybe 10 seconds to run! Unable to find image 'hello-world:latest' locally Trying to pull repository docker.io/library/hello-world ... latest: Pulling from library/hello-world 3f12c794407e: Pull complete 975b84d108f1: Pull complete Digest: sha256:8be990ef2aeb16dbcb9271ddfe2610fa6658d13f6dfb8bc72074cc1ca36966a7 Status: Downloaded newer image for docker.io/hello-world:latest Hello from Docker. This message shows that your installation appears to be working correctly. To generate this message, Docker took the following steps: 1. The Docker client contacted the Docker daemon. 2. The Docker daemon pulled the "hello-world" image from the Docker Hub. 3. The Docker daemon created a new container from that image which runs the executable that produces the output you are currently reading. 4. The Docker daemon streamed that output to the Docker client, which sent it to your terminal. To try something more ambitious, you can run an Ubuntu container with: $ docker run -it ubuntu bash Share images, automate workflows, and more with a free Docker Hub account: https://hub.docker.com For more examples and ideas, visit: https://docs.docker.com/userguide/ root@localhost /home/wpollock # docker images REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE docker.io/hello-world latest 975b84d108f1 10 weeks ago 960 B root@localhost /home/wpollock # cd .docker/ubuntu/ root@localhost /home/wpollock # ls -l total 4.0K -rw-rw-r--. 1 wpollock wpollock 12 Dec 24 17:51 Dockerfile root@localhost /home/wpollock # cat Dockerfile FROM ubuntu root@localhost /home/wpollock/.docker/ubuntu # docker build -t ubuntu-min . # "-t" names ("tags") the resulting image Sending build context to Docker daemon 2.048 kB Step 0 : FROM ubuntu Trying to pull repository docker.io/library/ubuntu ... latest: Pulling from library/ubuntu 9377ad319b00: Pull complete a82f81f25750: Pull complete b207c06aba70: Pull complete d55e68e6cc9c: Pull complete library/ubuntu: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:a2b67b6107aa640044c25a03b9e06e2a2d48c95be6ac17fb1a387e75eebafd7c Status: Downloaded newer image for docker.io/ubuntu:latest ---> d55e68e6cc9c Successfully built d55e68e6cc9c root@localhost /home/wpollock/.docker/ubuntu # docker images REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE docker.io/ubuntu latest d55e68e6cc9c 2 weeks ago 187.9 MB ubuntu-min latest d55e68e6cc9c 2 weeks ago 187.9 MB docker.io/hello-world latest 975b84d108f1 10 weeks ago 960 B root@localhost /home/wpollock/.docker/ubuntu # docker run -t ubuntu-min /bin/bash root@1fe09b2c32cf:/# hostname 1fe09b2c32cf root@1fe09b2c32cf:/# ps -ef UID PID PPID C STIME TTY TIME CMD root 1 0 0 23:28 ? 00:00:00 /bin/bash root 16 1 0 23:28 ? 00:00:00 ps -ef root@1fe09b2c32cf:/# exit exit root@localhost /home/wpollock/.docker/ubuntu # docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES b00b3f172c77 ubuntu-min "/bin/bash" 5 minutes ago Up 5 minutes distracted_morse e730f035b838 ubuntu-min "/bin/bash" 5 minutes ago Up 5 minutes cranky_aryabhata root@localhost /home/wpollock/.docker/ubuntu # docker stop b00b3f172c77 e730f035b83 b00b3f172c77 e730f035b83 root@localhost /home/wpollock/.docker/ubuntu # docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES root@localhost /home/wpollock/.docker/ubuntu # ### You can find many Docker images and Dockerfile examples on-line.