Docker; solving the dependency hell

What do you have and what do you want?

Moderators: b1o, jkerr82508

User avatar
viking60
Über-Berserk
Posts: 9351
Joined: 14 Mar 2010, 16:34

Docker; solving the dependency hell

Postby viking60 » 10 Jan 2017, 15:28

So everybody is talking about Docker these days - and b1o asked me to have a look at it:

It can run anything and will make a small OS that takes care of your dependencies.

Yes a Virtual Machine like Oracle's Virtualbox can do it too, but it requires a lot of resources. Docker will only bundle what you need to run your application.

Example:
If you need one server that runs PHP5 to make the old applications work and another server running PHP7 to make your newest apps work then docker can run both for you.

It will make containers that hold the right environment for you!

Sounds magic so I must try it of course:

Installation:

I found Docker in my standard Manjaro repo so i simply installed it.
Then I started and enabled the Docker service like this:

Code: Select all

sudo systemctl start docker.service

and

Code: Select all

sudo systemctl enable docker.service

I also did a:

Code: Select all

tee /etc/modules-load.d/loop.conf <<< "loop"

and

Code: Select all

modprobe loop

..because docker needs the loop module on the first run.
Since I want to use Docker as a regular user I added myself to the docker group

Code: Select all

sudo gpasswd -a viking60 docker

This will make me root every time with Docker.

Rebooted...and checked if Docker was running:
:A

Code: Select all

docker info

It came up with this:

Code: Select all

Containers: 0
 Running: 0
 Paused: 0
 Stopped: 0
Images: 0
Server Version: 1.12.5
Storage Driver: aufs
 Root Dir: /var/lib/docker/aufs
 Backing Filesystem: extfs
 Dirs: 0
 Dirperm1 Supported: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
 Volume: local
 Network: bridge host null overlay
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Security Options: seccomp
Kernel Version: 4.8.15-1-MANJARO
Operating System: Manjaro Linux
OSType: linux
Architecture: x86_64
CPUs: 8
Total Memory: 5.822 GiB
Name: thomas-pc
ID: 2WPO:JRI7:7UJM:OLPW:EXNT:JDUX:TYMA:GVSE:T6IT:OJ4U:KGFK:HSD4
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): false
Registry: https://index.docker.io/v1/
Insecure Registries:
 127.0.0.0/8

So far so good then time to start using this thing....

Using docker:

I am using Manjaro so time to pull a "different" OS aka Arch Linux:
:A

Code: Select all

docker pull base/archlinux

and it works!
:A

Code: Select all

docker pull base/archlinux
Using default tag: latest
latest: Pulling from base/archlinux
a3ed95caeb02: Pull complete
80ab36053684: Pull complete
Digest: sha256:7905fad7578b9852999935fb0ba9c32fe16cece9e4d1d742a34f55ce9cebdfd1
Status: Downloaded newer image for base/archlinux:latest

To check what Docker images i have - I do a:

Code: Select all

docker images

Which now indicates that I have archlinux at my disposal.

Wow ! Now I have to figure out howto pull Centos and Suse and Ubuntu and......

Time to search for centos then I simply typed:

Code: Select all

docker search centos

And there it was a huge list of images that I could use - the default Centos docker image is simply called "centos"

So here we go:

Code: Select all

docker pull centos

No problem there; the image was pulled so now I have a default Centos at my disposal too:

Code: Select all

~/ docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
centos              latest              67591570dd29        3 weeks ago         191.8 MB
base/archlinux      latest              f915fe624ef8        18 months ago       278.8 MB

Now let us see if we can start a container running Centos:

Code: Select all

docker run -ti centos

Yes!
I am in Centos and Yum works! :jackpot
I updated Centos and noticed that it comes without nano so I installed it:

Code: Select all

yum install nano

No problem :s

So now I can run a Centos server on my Manjaro box or simply run ArchLinux....
To see what OS' I have running I can simply type

Code: Select all

docker ps

As you can see - Centos is running

Code: Select all

~/ docker ps
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS         
c0d7812e056a        centos              "/bin/bash"         4 minutes ago       Up 4 minutes          tiny_borg


If you want to run GUI programs you need to install xorg-x11 in the container.
If you want to install a Centos server with wordpress running you can search for lamp and pull
nickistre/centos-lamp-wordpress
There are many Docker images that are "prepared" for you.

If you want to remove the docker image from your computer it is easily done like this;

Code: Select all

 docker rmi centos


To find the IP of the docker container I had to check the hostname and then do a:

Code: Select all

docker inspect 290e983aaf87 | grep IPAddress

290e983aaf87 beeing the hostname.
Doing ip addr or ifconfig will not help.

In my case the IP was something like 172.17.0.2

This might be because I use dnsmasq and dnscrypt that could influence the docker network interface.
Manjaro 64bit on the main box -Intel(R) Core(TM) i7 CPU 920 @ 2.67GHz and nVidia Corporation GT200b [GeForce GTX 275] (rev a1. + Centos on the server - Arch on the laptop.
"There are no stupid questions - Only stupid answers!"

User avatar
viking60
Über-Berserk
Posts: 9351
Joined: 14 Mar 2010, 16:34

Re: Docker; solving the dependency hell

Postby viking60 » 10 Jan 2017, 18:46

This thing is fast and does not take much resources.
The docker container will exploit the resources you already have and add what it needs in an isolated environment.
You can download docker images and play around with them and simply remove them without any garbage problems.

That is the difference between a VM and a container.

Image
Manjaro 64bit on the main box -Intel(R) Core(TM) i7 CPU 920 @ 2.67GHz and nVidia Corporation GT200b [GeForce GTX 275] (rev a1. + Centos on the server - Arch on the laptop.
"There are no stupid questions - Only stupid answers!"

User avatar
viking60
Über-Berserk
Posts: 9351
Joined: 14 Mar 2010, 16:34

Re: Docker is big business

Postby viking60 » 11 Jan 2017, 14:40

So you think this is a geeky nerdy thing done in the boys room?
Think again!
Docker is big business! +1
According to 451 Research, the market for application container technologies in 2016 generated $762 million in revenue. Looking forward to 2020, 451 Research is forecasting that 2020 revenue will reach $2.7 billion for a 40 percent compound annual growth rate.


More here
Manjaro 64bit on the main box -Intel(R) Core(TM) i7 CPU 920 @ 2.67GHz and nVidia Corporation GT200b [GeForce GTX 275] (rev a1. + Centos on the server - Arch on the laptop.
"There are no stupid questions - Only stupid answers!"

User avatar
viking60
Über-Berserk
Posts: 9351
Joined: 14 Mar 2010, 16:34

Re: Docker; GUI

Postby viking60 » 28 Feb 2018, 11:29

Docker is great but it works in other ways than we are used to so when I play around with it Docker will create a new instance every time. ..Yes this is a feature not a flaw!

But to keep track of all the features it would be handy to have an app to keep track of the docker images and manage them.

I tried the CLI variant - ctop- it is simple and should show all my instances but it does not.

So I went on to Portainer and it works like a charm!

I can see my active and non-active docker instances and I can turn them on and off like I please. :B

So here is what I did:

I wrote one command to get a web docker admin:

Code: Select all

docker run -d -p 9000:9000 --restart always -v /var/run/docker.sock:/var/run/docker.sock -v /opt/portainer:/data portainer/portainer


Then I went to my browser and entered localhost:9000 and there was a nice login where I had to create a password for the admin user and enter my local docker (you can admin external dockers too).

This was a user friendly process.

and oh wonder: :A
Image
Image
Nice!

To remember it - I made myself a Portainer alias:

Code: Select all

alias portainer='docker run -d -p 9000:9000 --restart always -v /var/run/docker.sock:/var/run/docker.sock -v /opt/portainer:/data portainer/portainer'


I am sure to forget it so I need the alias.

To make the config stick I created the data dir in /opt/portainer - that should avoid me starting from scratch every time.
Manjaro 64bit on the main box -Intel(R) Core(TM) i7 CPU 920 @ 2.67GHz and nVidia Corporation GT200b [GeForce GTX 275] (rev a1. + Centos on the server - Arch on the laptop.
"There are no stupid questions - Only stupid answers!"

Blackcrack
Posts: 300
Joined: 02 Apr 2013, 08:31

Re: Docker; solving the dependency hell

Postby Blackcrack » 01 Mar 2018, 07:18

cool ! to be exist something ... :)
a QTversion directly to add into an Control centre would also really pretty nice :)

best regards
Blacky


Return to “Software”