Wednesday, October 7, 2015

Digital pimp hard at work

Step 1 - Docker Installation
  A related video for this post

So you got yourself this bad ass new shiny Ubuntu guest on your virtual box, and now you are thinking "I can do this docker"
Well you can't, cause if you weren't having issues, you wouldn't have found this dank little corner of the interwebz. You just want to go back to your cat pictures and get your boss off your back.
You have seen the low res videos by the mouth breathers, the official docker videos, and the "fan made" tribute to docker where they all but jizz all over this technology because they were the first one to figure it out.
But enough of them, we are here to talk about me, let's get it rolling shall we.

The current lie is that the install works the same on Ubuntu as well as RHEL types, but I have not tried it yet. Well the first don't use the package manager to install it, if you did force remove it now, I'll wait.

First check the version just because,

[email protected]:~$ docker --version 
Docker version 1.0.1, build 990021a

See, it is too low of a version to be useful. REMOVE IT!

[email protected]:~$ sudo apt-get purge
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages were automatically installed and are no longer required:
  aufs-tools cgroup-lite git git-man liberror-perl
Use 'apt-get autoremove' to remove them.
The following packages will be REMOVED:*
0 upgraded, 0 newly installed, 1 to remove and 175 not upgraded.
After this operation, 24.7 MB disk space will be freed.
Do you want to continue? [Y/n] y
(Reading database ... 56762 files and directories currently installed.)
Removing (1.0.1~dfsg1-0ubuntu1~ubuntu0.14.04.1) ... stop/waiting
Purging configuration files for (1.0.1~dfsg1-0ubuntu1~ubuntu0.14.04.1) ...
Processing triggers for man-db ( ...
[email protected]:~$ docker --version 
-bash: /usr/bin/docker: No such file or directory

Now that is what we should do here is just use the funky curl program to install it, because why not curl it.
You don't even have to sudo it, the docker install script will do it all for you.

[email protected]:~$ curl -sSL | sh
apparmor is enabled in the kernel and apparmor utils were already installed

 Version:      1.8.1
 API version:  1.20
 Go version:   go1.4.2
 Git commit:   d12ea79
 Built:        Thu Aug 13 02:35:49 UTC 2015
 OS/Arch:      linux/amd64
If you would like to use Docker as a non-root user, you should now consider
adding your user to the "docker" group with something like:

  sudo usermod -aG docker hifi

Remember that you will have to log out and back in for this to take effect!

You can do the group mod or not, beware there is no audit trail with docker if you use the group for all your admins. Your call.

You want to test it now, so go ahead, do it, run the hello-world container. Make it grow like the hairs of your beard before your Friday night date. You know you want to touch it.

[email protected]:~$ sudo docker run hello-world 
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world

535020c3e8ad: Pull complete 
af340544ed62: Pull complete 
Digest: sha256:a68868bfe696c00866942e8f5ca39e3e31b79c1e50feaee4ce5e28df2f051d5c
Status: Downloaded newer image for 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, go ahead, flex those muscles. 
You can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker Hub account:

For more examples and ideas, visit:

Notice above, the image was not already on the system, so it pulled the image down and then ran it, only eating your precious little bits.

[email protected]:~$ sudo docker ps 
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES

Huh, how about that, there is no containers running. Well crap. Maybe we should verify it first?
Use the -a switch after docker ps to view all images that have run, and there it is. 

[email protected]:~$ sudo docker ps -a
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS                     PORTS               NAMES
18b47d59004c        hello-world         "/hello"            5 minutes ago       Exited (0) 5 minutes ago                       dreamy_pike

I wanna give it another whirl, this time with some slightly different switches to verify that things worked.
I am just going to test with the default ubuntu image and download that hot mess of 600MB

I did docker run -ti ubuntu /bin/bash to make it run it and give me the command prompt.
The switches here are defined as Interactive (i) and a pseudo-TTY (t) that will allow me to run bash interactively.

[email protected]:~$ sudo docker run -ti ubuntu /bin/bash 
Unable to find image 'ubuntu:latest' locally
latest: Pulling from library/ubuntu
d3a1f33e8a5a: Pull complete 
c22013c84729: Pull complete 
d74508fb6632: Pull complete 
91e54dfb1179: Already exists 
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:fde8a8814702c18bb1f39b3bd91a2f82a8e428b1b4e39d1963c5d14418da8fba
Status: Downloaded newer image for ubuntu:latest
[email protected]:/# 

Notice the prompt at the end there, [email protected]:/#
That says you are in the container and ready to go.
Once you exit the container it stops the docker process dies a horrible, lovely death as you get dropped back onto your standard command prompt

No comments:

Post a Comment