Docker -> fedora -> gluster .. Run gluster containers using docker … [part 1]

Everyone is talking about “docker” nowadays. I heard it can make life easier for a developer or sysadmin. If that is the case, we should try it 🙂

What is docker and how it works can be fetched from www.docker.io/
I was trying to explore docker and was trying to integrate it with gluster.. As part of the project [1], I created an image which is based on fedora 20 : The image has glusterfs packages installed and has a working ssh daemon..

If I need to run a glusterfs cluster based on fedora 20 , I just have to pull the image from centralized docker repo and fire a command.. And it’s ready and available to play with.

Check if the docker daemon is running:

[root@localhost glusterfs]# ps aux |grep docker
root 3202 0.2 0.8 706376 69592 pts/0 Sl+ May12 3:57 docker -d

If you don’t have docker installed, install docker packages according to the distribution (Fedora, CentOS, RHEL have docker binary in “docker-io” package).

Docker command provides many options to control containers, its images and much more.

For example:

[root@localhost glusterfs]# docker help
Usage: docker [OPTIONS] COMMAND [arg…]
-H=[unix:///var/run/docker.sock]: host:port to bind/connect to or path/to/socket to use

A self-sufficient runtime for linux containers.

Commands:
attach Attach to a running container
build Build a container from a Dockerfile
commit Create a new image from a container’s changes
cp Copy files/folders from the containers filesystem to the host path
diff Inspect changes on a container’s filesystem
events Get real time events from the server
export Stream the contents of a container as a tar archive
history Show the history of an image
images List images
import Create a new filesystem image from the contents of a tarball
info Display system-wide information
insert Insert a file in an image
inspect Return low-level information on a container
kill Kill a running container
load Load an image from a tar archive
login Register or Login to the docker registry server
logs Fetch the logs of a container
port Lookup the public-facing port which is NAT-ed to PRIVATE_PORT
ps List containers
pull Pull an image or a repository from the docker registry server
push Push an image or a repository to the docker registry server
restart Restart a running container
rm Remove one or more containers
rmi Remove one or more images
run Run a command in a new container
save Save an image to a tar archive
search Search for an image in the docker index
start Start a stopped container
stop Stop a running container
tag Tag an image into a repository
top Lookup the running processes of a container
version Show the docker version information
wait Block until a container stops, then print its exit code

[root@localhost glusterfs]#

For this lab, we need few commands like “search” , “pull”, “run”, “ps”..etc..

[root@localhost glusterfs]# docker search gluster
NAME DESCRIPTION STARS OFFICIAL TRUSTED
ferry/gluster GlusterFS image for Ferry. Ferry lets you … 0
humble/fed20-gluster Fedora 20 image with latest gluster packag… 0
danieldreier/glusterfs 0
vshankar/glusterfs 0
[root@localhost glusterfs]#

As of now, I can see there are 4 images available with tag “gluster”.
Let me pull one image, obviously I will try humble/fed20-gluster 🙂

[root@localhost glusterfs]# docker pull humble/fed20-gluster
Pulling repository humble/fed20-gluster
764261ddfd16: Download complete
511136ea3c5a: Download complete
ef52fb1fe610: Download complete
b7de3133ff98: Download complete
b76f2f7d32f3: Download complete
001547df7913: Download complete
02c56a55b851: Download complete
dad8c3afc9a7: Download complete
6aeab07d00fe: Download complete
753423d16579: Download complete
ab2ef80918d7: Download complete
728b19e17fba: Download complete
d408bb223c41: Download complete
8247941e1073: Download complete
[root@localhost glusterfs]#

Docker pulled this image repository and image is available with ID : “764261ddfd16″

[root@localhost dockit]# docker images
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
humble fed20-gluster 764261ddfd16 15 hours ago 1.562 GB
fedora 20 b7de3133ff98 2 weeks ago 372.7 MB
[root@localhost dockit]#

I am starting a container using the image 764261ddfd16

[root@localhost dockit]# docker run –privileged -d –name fedora20-gluster -i -t 764261ddfd16
59e9fea21d94c93e88c8cdfeff0718a2fdf7dd84550dc833e6da742f721c5f27

It executed successfully and we have a running container with name “fedora20-gluster”.

This newly started container can be listed as shown below:

[root@localhost dockit]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
59e9fea21d94 humble:fed20-gluster /usr/bin/supervisord 6 seconds ago Up 3 seconds 22/tcp fedora20-gluster
[root@localhost dockit]#

‘inspect’ option in docker command provides detailed information about the container as shown below.
We are interested in the IPAddress of this container. We can locate it by the container ID ’59e9fea21d94′.

[root@localhost glusterfs]# docker inspect –format='{{.NetworkSettings.IPAddress}}’ 59e9fea21d94
172.17.0.2
[root@localhost glusterfs]#

More verbose way to display other information:

[root@localhost dockit]# docker inspect 59e9fea21d94
[{
“ID”: “59e9fea21d94c93e88c8cdfeff0718a2fdf7dd84550dc833e6da742f721c5f27”,
“Created”: “2014-05-13T05:37:30.59215203Z”,
“Path”: “/usr/bin/supervisord”,
“Args”: [
“-n”
],
“Config”: {
“Hostname”: “59e9fea21d94”,
“Domainname”: “”,
“User”: “”,
“Memory”: 0,
“MemorySwap”: 0,
“CpuShares”: 0,
“AttachStdin”: false,
“AttachStdout”: false,
“AttachStderr”: false,
“PortSpecs”: null,
“ExposedPorts”: {
“22/tcp”: {}
},
“Tty”: true,
“OpenStdin”: true,
“StdinOnce”: false,
“Env”: [
“HOME=/”,
“PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin”
],
“Cmd”: null,
“Dns”: null,
“Image”: “764261ddfd16”,
“Volumes”: null,
“VolumesFrom”: “”,
“WorkingDir”: “”,
“Entrypoint”: [
“/usr/bin/supervisord”,
“-n”
],
“NetworkDisabled”: false,
“OnBuild”: null
},
“State”: {
“Running”: true,
“Pid”: 12306,
“ExitCode”: 0,
“StartedAt”: “2014-05-13T05:37:32.420278158Z”,
“FinishedAt”: “0001-01-01T00:00:00Z”,
“Ghost”: false
},
“Image”: “764261ddfd169b510d55b65f509092f85ccd1dbaa6599899ccceccc661d9”,
“NetworkSettings”: {
“IPAddress”: “172.17.0.2”, ———————>[2]
“IPPrefixLen”: 16,
“Gateway”: “172.17.42.1”,
“Bridge”: “docker0”,
“PortMapping”: null,
“Ports”: {
“22/tcp”: null
}
},
“ResolvConfPath”: “/etc/resolv.conf”,
“HostnamePath”: “/var/lib/docker/containers/59e9fea21d94c93e88c8cdfeff0718a2fdf7dd84550dc833e6da742f721c5f27/hostname”,
“HostsPath”: “/var/lib/docker/containers/59e9fea21d94c93e88c8cdfeff0718a2fdf7dd84550dc833e6da742f721c5f27/hosts”,
“Name”: “/fedora20-gluster”,
“Driver”: “devicemapper”,
“ExecDriver”: “native-0.1”,
“Volumes”: {},
“VolumesRW”: {},
“HostConfig”: {
“Binds”: null,
“ContainerIDFile”: “”,
“LxcConf”: [],
“Privileged”: false,
“PortBindings”: {
“22/tcp”: null
},
“Links”: null,
“PublishAllPorts”: false
}
}]

Ok… Now we know that ip address of the container is 172.17.0.2
Lets try to connect to the container via ssh:

[root@localhost dockit]# ssh root@172.17.0.2
The authenticity of host ‘172.17.0.2 (172.17.0.2)’ can’t be established.
RSA key fingerprint is c0:b6:86:7a:b6:61:21:f1:05:16:ee:62:c1:e8:d4:1f.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added ‘172.17.0.2’ (RSA) to the list of known hosts.
root@172.17.0.2’s password:

[root@59e9fea21d94 ~]# uname -a
Linux 59e9fea21d94 3.13.6-100.fc19.x86_64 #1 SMP Fri Mar 7 16:56:44 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux
[root@59e9fea21d94 ~]# cat /etc/redhat-release
Fedora release 20 (Heisenbug)
[root@59e9fea21d94 ~]#

[root@59e9fea21d94 ~]# hostname
59e9fea21d94
[root@59e9fea21d94 ~]#

[root@59e9fea21d94 ~]# rpm -qa |grep gluster
glusterfs-hadoop-javadoc-2.1.2-2.fc20.noarch
glusterfs-rdma-3.5.0-3.fc20.x86_64
glusterfs-server-3.5.0-3.fc20.x86_64
glusterfs-3.5.0-3.fc20.x86_64
glusterfs-fuse-3.5.0-3.fc20.x86_64
glusterfs-extra-xlators-3.5.0-3.fc20.x86_64
glusterfs-hadoop-2.1.2-2.fc20.noarch
glusterfs-resource-agents-3.5.0-3.fc20.noarch
glusterfs-api-devel-3.5.0-3.fc20.x86_64
glusterfs-libs-3.5.0-3.fc20.x86_64
glusterfs-api-3.5.0-3.fc20.x86_64
glusterfs-devel-3.5.0-3.fc20.x86_64
glusterfs-cli-3.5.0-3.fc20.x86_64
glusterfs-regression-tests-3.5.0-3.fc20.x86_64
glusterfs-geo-replication-3.5.0-3.fc20.x86_64
[root@59e9fea21d94 ~]# ps aux |grep ssh
root 11 0.0 0.0 82980 3552 ? S 05:37 0:00 /usr/sbin/sshd -D
root 12 0.2 0.0 131576 4824 ? Ss 05:56 0:00 sshd: root@pts/0
root 33 0.0 0.0 112668 968 pts/0 S+ 05:56 0:00 grep –color=auto ssh
[root@59e9fea21d94 ~]#

[root@59e9fea21d94 ~]# glusterd

[root@59e9fea21d94 ~]#
[root@59e9fea21d94 ~]# ps aux |grep gluster
root 46 0.1 0.1 271216 12792 ? Ssl 08:04 0:00 glusterd

[root@59e9fea21d94 ~]# gluster –version
glusterfs 3.5.0 built on May 1 2014 11:57:24
Repository revision: git.gluster.com/glusterfs.git
Copyright (c) 2006-2011 Gluster Inc.
GlusterFS comes with ABSOLUTELY NO WARRANTY.
You may redistribute copies of GlusterFS under the terms of the GNU General Public License.
[root@59e9fea21d94 ~]#

[1] incubating project:
github.com/humblec/dockit

1 thought on “Docker -> fedora -> gluster .. Run gluster containers using docker … [part 1]”

Comments are closed.