SlideShare a Scribd company logo
How to build a headless Ubuntu / XFCE with Docker & Dockerfish
Make sure you have Docker installed first and foremost.
Getting started
This tutorial demonstrates the ease of use of my tool Dockerfish which i coded from the ground up in pure Ruby
it requires no gems so there is no messing about.
I also showyou then how make a image from your containerwith ease also.
All you have todo is have git installed and most developers have it installed as a no brainer.
if not apt-get install git for Ubuntu / Debian or yum install git for Centos / Fedora etc ...
cd into the folder of your choice to download into then.
git clone https://github.com/puppetpies/DockerFish-CLI.git
Check if docker is running
systemctl status docker.service
docker.service - DockerApplicationContainer Engine
Loaded: loaded(/usr/lib/systemd/system/docker.service; enabled)
Active: active (running) since Fri 2015-06-26 10:21:28BST; 46minago
Docs: http://docs.docker.io
Process: 786 ExecStartPre=/usr/bin/mount --make-rprivate/ (code=exited, status=0/SUCCESS)
Main PID: 792 (docker)
CGroup: /system.slice/docker.service
792 /usr/bin/docker --api-enable-cors=true -H tcp://0.0.0.0:2375 -H unix:///var/run/docker.sock -d
Makingsure the APIis enabledyour docker.service ExecStart lineshouldlooklike this.
-H tcp://0.0.0.0:2375 - Youmay want torestrict this to certaininterface/ ip address as this what DockerFishwill access the API via.
cat /etc/systemd/system/multi-user.target.wants/docker.service
[Unit]
Description=DockerApplicationContainer Engine
Documentation=http://docs.docker.io
After=network.target
[Service]
ExecStartPre=/usr/bin/mount --make-rprivate /
ExecStart=/usr/bin/docker--api-enable-cors=true -H tcp://0.0.0.0:2375-H unix:///var/run/docker.sock -d
[Install]
WantedBy=multi-user.target
If you have had to make changes to this file then do the below.
systemctl daemon-reload
Then restart Docker where convieniant.
systemctl restart docker.service
Now check if Docker has started up correctly systemctl status docker.service if all is well lets download Ubuntu.
docker pull ubuntu
This may take sometime but its worth the wait.
Introduction to Dockerfish
Make yourdockerfish.rb executable
chmod 755 dockerfish.rb
symlink to /usr/bin # You need root for this and optional
ln -s dockerfish.rb /usr/bin/dockerfish
./dockerfish.rb
Welcome toDockerFishVersion 0.1
---------------------------------
Interactive CLIDocker Interface
[] |
|
,|.
,|/.
,' .V. `.
/ . . /_`
|@)| . . |(@|
,-._ `._'; . :`_,'_,-.
'-- `- /,-===-. /-' --`
(---- _| ||___|| |_ ----)
`._,-' `-.-' / `-._,'
`-.___,-' ap[]
TIPS: Please note ContainerId's / Names are interchangeable
Youcan also use short ContainerId's as longas there is a unique match
Start with Docker API Enabled: /usr/bin/docker --api-enable-cors=true -H tcp://127.0.0.1:2375 -H unix:///var/run/docker.sock -d
Add a symlink ln -s /home/brian/Projects/DockerFish/dockerfish.rb/usr/bin/dockerfish
--help # For more information
Enjoy!
Coded by Brian Hood
Server Info:
{"ApiVersion"=>"1.18",
"Arch"=>"amd64",
"GitCommit"=>"a61716e",
"GoVersion"=>"go1.4.2",
"KernelVersion"=>"3.14.5-1-ARCH",
"Os"=>"linux",
"Version"=>"1.5.0-dev"}
DockerFish> 1
List of DockerImages
=====================
Created: 2015-06-12 16:32:30 Id: 6d4946999d4fb403f4 Image: ["ubuntu:latest"] Size: 8B VirtualSize: 179.563MB
You now have the latest Ubuntu image at your finger tips great so what now ?
The first step is press 6 and hit enter.
6) Create Container from Image
Enter Image touse> ubuntu:latest
Example: name orname1,name2,name3
Enter Container name(s)> ubuntu-xfce-headless
{
"Hostname":"ubuntu-xfce-headless",
"User":"",
"Memory":0,
"MemorySwap":0,
"CpuShares":0,
"AttachStdin":true,
"AttachStdout":true,
"AttachStderr":true,
"PortSpecs":null,
"Tty":true,
"OpenStdin":true,
"StdinOnce":true,
"Env":null,
"Cmd":[
"/bin/bash"
],
"Dns":null,
"Image":"ubuntu:latest",
"VolumesFrom":"",
"WorkingDir":"",
"HostConfig": {
"NetworkMode": "bridge",
"Devices": []
}
}
ContainerCreationSuccessfull
DockerFish> 2
List of DockerContainers
=========================
Command: /bin/bash ContainerId: 5073abe5f5c9 Image: ubuntu:latest Names: ["/ubuntu-xfce-headless"] Status:
Ok lets start up your container.
Press 3
DockerFish> 3
Enter Container to Start> ubuntu-xfce-headless
StartingContainer ubuntu-xfce-headless
Start Successfull
DockerFish> 2
List of DockerContainers
=========================
Command: /bin/bash ContainerId: 5073abe5f5c9 Image: ubuntu:latest Names: ["/ubuntu-xfce-headless"] Status: Up 48 seconds
Was it really that easy to yes in short now you just have todo the configuration in the next step.
Build your machine from scratch
Startup and Terminal
To attach to your docker instance run the folllowing.
docker attach ubuntu-xfce-headless
Then hit enter again to enter the container.
[brian@orville ~]$dockerattachubuntu-xfce-headless
root@ubuntu-xfce-headless:/# apt-get update
Ign http://archive.ubuntu.comtrustyInRelease
Ign http://archive.ubuntu.comtrusty-updates InRelease
Ign http://archive.ubuntu.comtrusty-securityInRelease
Hit http://archive.ubuntu.com trusty Release.gpg
Get:1 http://archive.ubuntu.com trusty-updates Release.gpg[933 B]
Get:2 http://archive.ubuntu.com trusty-securityRelease.gpg[933 B]
-- OMITTED --
Ok so youobtainedthe latest Ubunturepository dataif youdon’t knowwhat the means don’t worry.
Next downloadXFCE4
root@ubuntu-xfce-headless:/# apt-get install xfce4xvfbx11vnc
Readingpackage lists... Done
Building dependency tree
Readingstate information... Done
The followingextra packages will be installed:
-- OMITTED LOTSOF PACKAGES--
2 upgraded, 384 newly installed, 0 toremove and9 not upgraded.
Needto get 94.4 MB ofarchives.
After this operation,378MB of additional disk space will be used.
Do youwant to continue? [Y/n]
Press Y enter and sit back and relax read a book etc ...
Setup VNC / Xvfb
root@ubuntu-xfce-headless:/# mkdir ~/.vnc
root@ubuntu-xfce-headless:/# x11vnc -storepasswdletmein ~/.vnc/passwd
root@ubuntu-xfce-headless:/# Xvfb:1 -extensionGLX -screen0 1024x780x24 &
root@ubuntu-xfce-headless:/# DISPLAY=:1 /usr/bin/xfce4-session&
root@ubuntu-xfce-headless:/# x11vnc -usepw-forever-display:1 &
cat > start_session.sh
Xvfb:1 -extensionGLX -screen0 1024x780x24&
sleep 2
DISPLAY=:1 /usr/bin/xfce4-session &
sleep 2
x11vnc-usepw-forever -display:1 &
Press CTRL+C
chmod755 start_session.sh
When youstart yourDocker container youcan nowjust go.
./start_session.sh
See what your DockercontainerIP is.
root@ubuntu-xfce-headless:/# ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu65536qdisc noqueue state UNKNOWN group default
link/loopback00:00:00:00:00:00brd00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft foreverpreferred_lft forever
inet6 ::1/128scope host
valid_lft foreverpreferred_lft forever
5: eth0: <BROADCAST,UP,LOWER_UP> mtu1500 qdisc noqueue state UP group default
link/ether 02:42:ac:11:00:01brdff:ff:ff:ff:ff:ff
inet 172.17.0.1/16scopeglobal eth0
valid_lft foreverpreferred_lft forever
inet6 fe80::42:acff:fe11:1/64 scope link
valid_lft foreverpreferred_lft forever
Install a VNC Viewer like tigervnc on your host OS and connect to 172.17.0.1:0 this will
default to port 5900 using display port 0
Everything now working !
I recommend that you go into yoursettings in XFCE and configure the appearance as i had no icons until i
selected Tango from the icons menu.
Ok now as promised you have your Ubuntu with XFCE running underDocker.
Now lets make this container into its own Image so i can make as many of these as i want the question is how.
Thats easy.
First detach from your
root@ubuntu-xfce-headless:/# exit
Go back to your Dockerfish terminal.
DockerFish> 2
List of DockerContainers
=========================
Command: /bin/bash ContainerId: 5073abe5f5c9 Image: ubuntu:latest Names: ["/ubuntu-xfce-headless"] Status: Exited(0)
About a minute ago
You can see that it has exited which you need to create a image from it.
DockerFish> 15
Enter Container to Image> ubuntu-xfce-headless
Enter your commit comment important> UbuntuXFCE Headless
Enter your Repositoryname> devel/headless-ubuntu-vnc
Image Commit Successfull
How do i check if it worked ?
DockerFish> 1
List of DockerImages
=====================
Created: 2015-06-26 13:14:16 Id: 97a9b89d37cf63b41e Image: ["devel/headless-ubuntu-vnc:latest"] Size: 501.381MB
VirtualSize: 680.944MB
Nowyou’ve createdyour image your free tocustomize it by makingmore containers andmakingtheminto images.
Enjoy !
Brian Hood
Dockerfish-Tutorial

More Related Content

What's hot

How Puppet Enables the Use of Lightweight Virtualized Containers - PuppetConf...
How Puppet Enables the Use of Lightweight Virtualized Containers - PuppetConf...How Puppet Enables the Use of Lightweight Virtualized Containers - PuppetConf...
How Puppet Enables the Use of Lightweight Virtualized Containers - PuppetConf...
Puppet
 
Docker puppetcamp london 2013
Docker puppetcamp london 2013Docker puppetcamp london 2013
Docker puppetcamp london 2013
Tomas Doran
 
Vagrant
VagrantVagrant
JavaCro'15 - Conquer the Internet of Things with Java and Docker - Johan Jans...
JavaCro'15 - Conquer the Internet of Things with Java and Docker - Johan Jans...JavaCro'15 - Conquer the Internet of Things with Java and Docker - Johan Jans...
JavaCro'15 - Conquer the Internet of Things with Java and Docker - Johan Jans...
HUJAK - Hrvatska udruga Java korisnika / Croatian Java User Association
 
Continuous delivery with docker
Continuous delivery with dockerContinuous delivery with docker
Continuous delivery with docker
Johan Janssen
 
Docker for Java developers at JavaLand
Docker for Java developers at JavaLandDocker for Java developers at JavaLand
Docker for Java developers at JavaLand
Johan Janssen
 
Simplify and run your development environments with Vagrant on OpenStack
Simplify and run your development environments with Vagrant on OpenStackSimplify and run your development environments with Vagrant on OpenStack
Simplify and run your development environments with Vagrant on OpenStack
B1 Systems GmbH
 
Docker deploy
Docker deployDocker deploy
Docker deploy
Eric Ahn
 
Building and Testing from Scratch a Puppet Environment with Docker - PuppetCo...
Building and Testing from Scratch a Puppet Environment with Docker - PuppetCo...Building and Testing from Scratch a Puppet Environment with Docker - PuppetCo...
Building and Testing from Scratch a Puppet Environment with Docker - PuppetCo...
Puppet
 
Rally_Docker_deployment_JumpVM
Rally_Docker_deployment_JumpVMRally_Docker_deployment_JumpVM
Rally_Docker_deployment_JumpVM
J. Kristian Gonzalez
 
Deploying Symfony2 app with Ansible
Deploying Symfony2 app with AnsibleDeploying Symfony2 app with Ansible
Deploying Symfony2 app with Ansible
Roman Rodomansky
 
Gebruik dezelfde Docker container voor Java applicaties tijdens ontwikkelen e...
Gebruik dezelfde Docker container voor Java applicaties tijdens ontwikkelen e...Gebruik dezelfde Docker container voor Java applicaties tijdens ontwikkelen e...
Gebruik dezelfde Docker container voor Java applicaties tijdens ontwikkelen e...
NLJUG
 
Python virtualenv & pip in 90 minutes
Python virtualenv & pip in 90 minutesPython virtualenv & pip in 90 minutes
Python virtualenv & pip in 90 minutes
Larry Cai
 
Infrastructure testing with Jenkins, Puppet and Vagrant - Agile Testing Days ...
Infrastructure testing with Jenkins, Puppet and Vagrant - Agile Testing Days ...Infrastructure testing with Jenkins, Puppet and Vagrant - Agile Testing Days ...
Infrastructure testing with Jenkins, Puppet and Vagrant - Agile Testing Days ...
Carlos Sanchez
 
Real World Experience of Running Docker in Development and Production
Real World Experience of Running Docker in Development and ProductionReal World Experience of Running Docker in Development and Production
Real World Experience of Running Docker in Development and Production
Ben Hall
 
Getting instantly up and running with Docker and Symfony
Getting instantly up and running with Docker and SymfonyGetting instantly up and running with Docker and Symfony
Getting instantly up and running with Docker and Symfony
André Rømcke
 
Meetup C++ Floripa - Conan.io
Meetup C++ Floripa - Conan.ioMeetup C++ Floripa - Conan.io
Meetup C++ Floripa - Conan.io
Uilian Ries
 
Docker workshop DevOpsDays Amsterdam 2014
Docker workshop DevOpsDays Amsterdam 2014Docker workshop DevOpsDays Amsterdam 2014
Docker workshop DevOpsDays Amsterdam 2014
Pini Reznik
 
Install openstack
Install openstackInstall openstack
Install openstack
어형 이
 
Conan a C/C++ Package Manager
Conan a C/C++ Package ManagerConan a C/C++ Package Manager
Conan a C/C++ Package Manager
Uilian Ries
 

What's hot (20)

How Puppet Enables the Use of Lightweight Virtualized Containers - PuppetConf...
How Puppet Enables the Use of Lightweight Virtualized Containers - PuppetConf...How Puppet Enables the Use of Lightweight Virtualized Containers - PuppetConf...
How Puppet Enables the Use of Lightweight Virtualized Containers - PuppetConf...
 
Docker puppetcamp london 2013
Docker puppetcamp london 2013Docker puppetcamp london 2013
Docker puppetcamp london 2013
 
Vagrant
VagrantVagrant
Vagrant
 
JavaCro'15 - Conquer the Internet of Things with Java and Docker - Johan Jans...
JavaCro'15 - Conquer the Internet of Things with Java and Docker - Johan Jans...JavaCro'15 - Conquer the Internet of Things with Java and Docker - Johan Jans...
JavaCro'15 - Conquer the Internet of Things with Java and Docker - Johan Jans...
 
Continuous delivery with docker
Continuous delivery with dockerContinuous delivery with docker
Continuous delivery with docker
 
Docker for Java developers at JavaLand
Docker for Java developers at JavaLandDocker for Java developers at JavaLand
Docker for Java developers at JavaLand
 
Simplify and run your development environments with Vagrant on OpenStack
Simplify and run your development environments with Vagrant on OpenStackSimplify and run your development environments with Vagrant on OpenStack
Simplify and run your development environments with Vagrant on OpenStack
 
Docker deploy
Docker deployDocker deploy
Docker deploy
 
Building and Testing from Scratch a Puppet Environment with Docker - PuppetCo...
Building and Testing from Scratch a Puppet Environment with Docker - PuppetCo...Building and Testing from Scratch a Puppet Environment with Docker - PuppetCo...
Building and Testing from Scratch a Puppet Environment with Docker - PuppetCo...
 
Rally_Docker_deployment_JumpVM
Rally_Docker_deployment_JumpVMRally_Docker_deployment_JumpVM
Rally_Docker_deployment_JumpVM
 
Deploying Symfony2 app with Ansible
Deploying Symfony2 app with AnsibleDeploying Symfony2 app with Ansible
Deploying Symfony2 app with Ansible
 
Gebruik dezelfde Docker container voor Java applicaties tijdens ontwikkelen e...
Gebruik dezelfde Docker container voor Java applicaties tijdens ontwikkelen e...Gebruik dezelfde Docker container voor Java applicaties tijdens ontwikkelen e...
Gebruik dezelfde Docker container voor Java applicaties tijdens ontwikkelen e...
 
Python virtualenv & pip in 90 minutes
Python virtualenv & pip in 90 minutesPython virtualenv & pip in 90 minutes
Python virtualenv & pip in 90 minutes
 
Infrastructure testing with Jenkins, Puppet and Vagrant - Agile Testing Days ...
Infrastructure testing with Jenkins, Puppet and Vagrant - Agile Testing Days ...Infrastructure testing with Jenkins, Puppet and Vagrant - Agile Testing Days ...
Infrastructure testing with Jenkins, Puppet and Vagrant - Agile Testing Days ...
 
Real World Experience of Running Docker in Development and Production
Real World Experience of Running Docker in Development and ProductionReal World Experience of Running Docker in Development and Production
Real World Experience of Running Docker in Development and Production
 
Getting instantly up and running with Docker and Symfony
Getting instantly up and running with Docker and SymfonyGetting instantly up and running with Docker and Symfony
Getting instantly up and running with Docker and Symfony
 
Meetup C++ Floripa - Conan.io
Meetup C++ Floripa - Conan.ioMeetup C++ Floripa - Conan.io
Meetup C++ Floripa - Conan.io
 
Docker workshop DevOpsDays Amsterdam 2014
Docker workshop DevOpsDays Amsterdam 2014Docker workshop DevOpsDays Amsterdam 2014
Docker workshop DevOpsDays Amsterdam 2014
 
Install openstack
Install openstackInstall openstack
Install openstack
 
Conan a C/C++ Package Manager
Conan a C/C++ Package ManagerConan a C/C++ Package Manager
Conan a C/C++ Package Manager
 

Similar to Dockerfish-Tutorial

Docker in Action
Docker in ActionDocker in Action
Docker in Action
Alper Kanat
 
Lab docker
Lab dockerLab docker
Lab docker
Bruno Cornec
 
Docker practice
Docker practiceDocker practice
Docker practice
wonyong hwang
 
Hide your development environment and application in a container
Hide your development environment and application in a containerHide your development environment and application in a container
Hide your development environment and application in a container
Johan Janssen
 
Puppet Camp Chicago 2014: Docker and Puppet: 1+1=3 (Intermediate)
Puppet Camp Chicago 2014: Docker and Puppet: 1+1=3 (Intermediate)Puppet Camp Chicago 2014: Docker and Puppet: 1+1=3 (Intermediate)
Puppet Camp Chicago 2014: Docker and Puppet: 1+1=3 (Intermediate)
Puppet
 
Introducing Docker
Introducing DockerIntroducing Docker
Introducing Docker
Francesco Pantano
 
The Dockerfile Explosion and the Need for Higher Level Tools by Gareth Rushgrove
The Dockerfile Explosion and the Need for Higher Level Tools by Gareth RushgroveThe Dockerfile Explosion and the Need for Higher Level Tools by Gareth Rushgrove
The Dockerfile Explosion and the Need for Higher Level Tools by Gareth Rushgrove
Docker, Inc.
 
Docker for mere mortals
Docker for mere mortalsDocker for mere mortals
Docker for mere mortals
Henryk Konsek
 
Docker, c'est bonheur !
Docker, c'est bonheur !Docker, c'est bonheur !
Docker, c'est bonheur !
Alexandre Salomé
 
JDO 2019: Tips and Tricks from Docker Captain - Łukasz Lach
JDO 2019: Tips and Tricks from Docker Captain - Łukasz LachJDO 2019: Tips and Tricks from Docker Captain - Łukasz Lach
JDO 2019: Tips and Tricks from Docker Captain - Łukasz Lach
PROIDEA
 
Hands-On Session Docker
Hands-On Session DockerHands-On Session Docker
Hands-On Session Docker
LinetsChile
 
Pursue container architecture with mincs
Pursue container architecture with mincsPursue container architecture with mincs
Pursue container architecture with mincs
Yuki Nishiwaki
 
Dockerizing Symfony Applications - Symfony Live Berlin 2014
Dockerizing Symfony Applications - Symfony Live Berlin 2014Dockerizing Symfony Applications - Symfony Live Berlin 2014
Dockerizing Symfony Applications - Symfony Live Berlin 2014
D
 
Introduction to docker
Introduction to dockerIntroduction to docker
Introduction to docker
Jim Yeh
 
Docker - A Ruby Introduction
Docker - A Ruby IntroductionDocker - A Ruby Introduction
Docker - A Ruby Introduction
Tyler Johnston
 
The Docker "Gauntlet" - Introduction, Ecosystem, Deployment, Orchestration
The Docker "Gauntlet" - Introduction, Ecosystem, Deployment, OrchestrationThe Docker "Gauntlet" - Introduction, Ecosystem, Deployment, Orchestration
The Docker "Gauntlet" - Introduction, Ecosystem, Deployment, Orchestration
Erica Windisch
 
Os dev tool box
Os dev tool boxOs dev tool box
Os dev tool box
bpowell29a
 
codemotion-docker-2014
codemotion-docker-2014codemotion-docker-2014
codemotion-docker-2014
Carlo Bonamico
 
From zero to Docker
From zero to DockerFrom zero to Docker
From zero to Docker
Giovanni Toraldo
 
docker installation and basics
docker installation and basicsdocker installation and basics
docker installation and basics
Walid Ashraf
 

Similar to Dockerfish-Tutorial (20)

Docker in Action
Docker in ActionDocker in Action
Docker in Action
 
Lab docker
Lab dockerLab docker
Lab docker
 
Docker practice
Docker practiceDocker practice
Docker practice
 
Hide your development environment and application in a container
Hide your development environment and application in a containerHide your development environment and application in a container
Hide your development environment and application in a container
 
Puppet Camp Chicago 2014: Docker and Puppet: 1+1=3 (Intermediate)
Puppet Camp Chicago 2014: Docker and Puppet: 1+1=3 (Intermediate)Puppet Camp Chicago 2014: Docker and Puppet: 1+1=3 (Intermediate)
Puppet Camp Chicago 2014: Docker and Puppet: 1+1=3 (Intermediate)
 
Introducing Docker
Introducing DockerIntroducing Docker
Introducing Docker
 
The Dockerfile Explosion and the Need for Higher Level Tools by Gareth Rushgrove
The Dockerfile Explosion and the Need for Higher Level Tools by Gareth RushgroveThe Dockerfile Explosion and the Need for Higher Level Tools by Gareth Rushgrove
The Dockerfile Explosion and the Need for Higher Level Tools by Gareth Rushgrove
 
Docker for mere mortals
Docker for mere mortalsDocker for mere mortals
Docker for mere mortals
 
Docker, c'est bonheur !
Docker, c'est bonheur !Docker, c'est bonheur !
Docker, c'est bonheur !
 
JDO 2019: Tips and Tricks from Docker Captain - Łukasz Lach
JDO 2019: Tips and Tricks from Docker Captain - Łukasz LachJDO 2019: Tips and Tricks from Docker Captain - Łukasz Lach
JDO 2019: Tips and Tricks from Docker Captain - Łukasz Lach
 
Hands-On Session Docker
Hands-On Session DockerHands-On Session Docker
Hands-On Session Docker
 
Pursue container architecture with mincs
Pursue container architecture with mincsPursue container architecture with mincs
Pursue container architecture with mincs
 
Dockerizing Symfony Applications - Symfony Live Berlin 2014
Dockerizing Symfony Applications - Symfony Live Berlin 2014Dockerizing Symfony Applications - Symfony Live Berlin 2014
Dockerizing Symfony Applications - Symfony Live Berlin 2014
 
Introduction to docker
Introduction to dockerIntroduction to docker
Introduction to docker
 
Docker - A Ruby Introduction
Docker - A Ruby IntroductionDocker - A Ruby Introduction
Docker - A Ruby Introduction
 
The Docker "Gauntlet" - Introduction, Ecosystem, Deployment, Orchestration
The Docker "Gauntlet" - Introduction, Ecosystem, Deployment, OrchestrationThe Docker "Gauntlet" - Introduction, Ecosystem, Deployment, Orchestration
The Docker "Gauntlet" - Introduction, Ecosystem, Deployment, Orchestration
 
Os dev tool box
Os dev tool boxOs dev tool box
Os dev tool box
 
codemotion-docker-2014
codemotion-docker-2014codemotion-docker-2014
codemotion-docker-2014
 
From zero to Docker
From zero to DockerFrom zero to Docker
From zero to Docker
 
docker installation and basics
docker installation and basicsdocker installation and basics
docker installation and basics
 

Dockerfish-Tutorial

  • 1. How to build a headless Ubuntu / XFCE with Docker & Dockerfish Make sure you have Docker installed first and foremost. Getting started This tutorial demonstrates the ease of use of my tool Dockerfish which i coded from the ground up in pure Ruby it requires no gems so there is no messing about. I also showyou then how make a image from your containerwith ease also. All you have todo is have git installed and most developers have it installed as a no brainer. if not apt-get install git for Ubuntu / Debian or yum install git for Centos / Fedora etc ... cd into the folder of your choice to download into then. git clone https://github.com/puppetpies/DockerFish-CLI.git Check if docker is running systemctl status docker.service docker.service - DockerApplicationContainer Engine Loaded: loaded(/usr/lib/systemd/system/docker.service; enabled) Active: active (running) since Fri 2015-06-26 10:21:28BST; 46minago Docs: http://docs.docker.io Process: 786 ExecStartPre=/usr/bin/mount --make-rprivate/ (code=exited, status=0/SUCCESS) Main PID: 792 (docker) CGroup: /system.slice/docker.service 792 /usr/bin/docker --api-enable-cors=true -H tcp://0.0.0.0:2375 -H unix:///var/run/docker.sock -d Makingsure the APIis enabledyour docker.service ExecStart lineshouldlooklike this. -H tcp://0.0.0.0:2375 - Youmay want torestrict this to certaininterface/ ip address as this what DockerFishwill access the API via. cat /etc/systemd/system/multi-user.target.wants/docker.service [Unit] Description=DockerApplicationContainer Engine Documentation=http://docs.docker.io After=network.target [Service] ExecStartPre=/usr/bin/mount --make-rprivate / ExecStart=/usr/bin/docker--api-enable-cors=true -H tcp://0.0.0.0:2375-H unix:///var/run/docker.sock -d [Install] WantedBy=multi-user.target If you have had to make changes to this file then do the below. systemctl daemon-reload Then restart Docker where convieniant. systemctl restart docker.service
  • 2. Now check if Docker has started up correctly systemctl status docker.service if all is well lets download Ubuntu. docker pull ubuntu This may take sometime but its worth the wait. Introduction to Dockerfish Make yourdockerfish.rb executable chmod 755 dockerfish.rb symlink to /usr/bin # You need root for this and optional ln -s dockerfish.rb /usr/bin/dockerfish ./dockerfish.rb Welcome toDockerFishVersion 0.1 --------------------------------- Interactive CLIDocker Interface [] | | ,|. ,|/. ,' .V. `. / . . /_` |@)| . . |(@| ,-._ `._'; . :`_,'_,-. '-- `- /,-===-. /-' --` (---- _| ||___|| |_ ----) `._,-' `-.-' / `-._,' `-.___,-' ap[] TIPS: Please note ContainerId's / Names are interchangeable Youcan also use short ContainerId's as longas there is a unique match Start with Docker API Enabled: /usr/bin/docker --api-enable-cors=true -H tcp://127.0.0.1:2375 -H unix:///var/run/docker.sock -d Add a symlink ln -s /home/brian/Projects/DockerFish/dockerfish.rb/usr/bin/dockerfish --help # For more information Enjoy! Coded by Brian Hood Server Info: {"ApiVersion"=>"1.18", "Arch"=>"amd64", "GitCommit"=>"a61716e", "GoVersion"=>"go1.4.2", "KernelVersion"=>"3.14.5-1-ARCH", "Os"=>"linux", "Version"=>"1.5.0-dev"} DockerFish> 1 List of DockerImages ===================== Created: 2015-06-12 16:32:30 Id: 6d4946999d4fb403f4 Image: ["ubuntu:latest"] Size: 8B VirtualSize: 179.563MB You now have the latest Ubuntu image at your finger tips great so what now ? The first step is press 6 and hit enter.
  • 3. 6) Create Container from Image Enter Image touse> ubuntu:latest Example: name orname1,name2,name3 Enter Container name(s)> ubuntu-xfce-headless { "Hostname":"ubuntu-xfce-headless", "User":"", "Memory":0, "MemorySwap":0, "CpuShares":0, "AttachStdin":true, "AttachStdout":true, "AttachStderr":true, "PortSpecs":null, "Tty":true, "OpenStdin":true, "StdinOnce":true, "Env":null, "Cmd":[ "/bin/bash" ], "Dns":null, "Image":"ubuntu:latest", "VolumesFrom":"", "WorkingDir":"", "HostConfig": { "NetworkMode": "bridge", "Devices": [] } } ContainerCreationSuccessfull DockerFish> 2 List of DockerContainers ========================= Command: /bin/bash ContainerId: 5073abe5f5c9 Image: ubuntu:latest Names: ["/ubuntu-xfce-headless"] Status: Ok lets start up your container. Press 3 DockerFish> 3 Enter Container to Start> ubuntu-xfce-headless StartingContainer ubuntu-xfce-headless Start Successfull DockerFish> 2 List of DockerContainers ========================= Command: /bin/bash ContainerId: 5073abe5f5c9 Image: ubuntu:latest Names: ["/ubuntu-xfce-headless"] Status: Up 48 seconds Was it really that easy to yes in short now you just have todo the configuration in the next step. Build your machine from scratch Startup and Terminal To attach to your docker instance run the folllowing. docker attach ubuntu-xfce-headless
  • 4. Then hit enter again to enter the container. [brian@orville ~]$dockerattachubuntu-xfce-headless root@ubuntu-xfce-headless:/# apt-get update Ign http://archive.ubuntu.comtrustyInRelease Ign http://archive.ubuntu.comtrusty-updates InRelease Ign http://archive.ubuntu.comtrusty-securityInRelease Hit http://archive.ubuntu.com trusty Release.gpg Get:1 http://archive.ubuntu.com trusty-updates Release.gpg[933 B] Get:2 http://archive.ubuntu.com trusty-securityRelease.gpg[933 B] -- OMITTED -- Ok so youobtainedthe latest Ubunturepository dataif youdon’t knowwhat the means don’t worry. Next downloadXFCE4 root@ubuntu-xfce-headless:/# apt-get install xfce4xvfbx11vnc Readingpackage lists... Done Building dependency tree Readingstate information... Done The followingextra packages will be installed: -- OMITTED LOTSOF PACKAGES-- 2 upgraded, 384 newly installed, 0 toremove and9 not upgraded. Needto get 94.4 MB ofarchives. After this operation,378MB of additional disk space will be used. Do youwant to continue? [Y/n] Press Y enter and sit back and relax read a book etc ... Setup VNC / Xvfb root@ubuntu-xfce-headless:/# mkdir ~/.vnc root@ubuntu-xfce-headless:/# x11vnc -storepasswdletmein ~/.vnc/passwd root@ubuntu-xfce-headless:/# Xvfb:1 -extensionGLX -screen0 1024x780x24 & root@ubuntu-xfce-headless:/# DISPLAY=:1 /usr/bin/xfce4-session& root@ubuntu-xfce-headless:/# x11vnc -usepw-forever-display:1 & cat > start_session.sh Xvfb:1 -extensionGLX -screen0 1024x780x24& sleep 2 DISPLAY=:1 /usr/bin/xfce4-session & sleep 2 x11vnc-usepw-forever -display:1 & Press CTRL+C chmod755 start_session.sh When youstart yourDocker container youcan nowjust go. ./start_session.sh See what your DockercontainerIP is. root@ubuntu-xfce-headless:/# ip addr 1: lo: <LOOPBACK,UP,LOWER_UP> mtu65536qdisc noqueue state UNKNOWN group default link/loopback00:00:00:00:00:00brd00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft foreverpreferred_lft forever inet6 ::1/128scope host valid_lft foreverpreferred_lft forever 5: eth0: <BROADCAST,UP,LOWER_UP> mtu1500 qdisc noqueue state UP group default link/ether 02:42:ac:11:00:01brdff:ff:ff:ff:ff:ff inet 172.17.0.1/16scopeglobal eth0
  • 5. valid_lft foreverpreferred_lft forever inet6 fe80::42:acff:fe11:1/64 scope link valid_lft foreverpreferred_lft forever Install a VNC Viewer like tigervnc on your host OS and connect to 172.17.0.1:0 this will default to port 5900 using display port 0 Everything now working ! I recommend that you go into yoursettings in XFCE and configure the appearance as i had no icons until i selected Tango from the icons menu. Ok now as promised you have your Ubuntu with XFCE running underDocker. Now lets make this container into its own Image so i can make as many of these as i want the question is how. Thats easy. First detach from your root@ubuntu-xfce-headless:/# exit Go back to your Dockerfish terminal. DockerFish> 2 List of DockerContainers ========================= Command: /bin/bash ContainerId: 5073abe5f5c9 Image: ubuntu:latest Names: ["/ubuntu-xfce-headless"] Status: Exited(0) About a minute ago You can see that it has exited which you need to create a image from it. DockerFish> 15 Enter Container to Image> ubuntu-xfce-headless Enter your commit comment important> UbuntuXFCE Headless Enter your Repositoryname> devel/headless-ubuntu-vnc Image Commit Successfull How do i check if it worked ? DockerFish> 1 List of DockerImages ===================== Created: 2015-06-26 13:14:16 Id: 97a9b89d37cf63b41e Image: ["devel/headless-ubuntu-vnc:latest"] Size: 501.381MB VirtualSize: 680.944MB Nowyou’ve createdyour image your free tocustomize it by makingmore containers andmakingtheminto images. Enjoy ! Brian Hood