My Lab

Lab Docker Host

Ok getting this blog back on track we will need a docker host or two for easily setting up of Lab solutions.

What is Docker ?

Docker is the abstraction of the application from the Operating System what this means is you can separate the OS and the app, you can run multiple application on top of a single OS without the application dependency and environment variables getting in the way with each other.
This means less overhead and more efficient use out of the hardware you have as you don’t need a full OS stack when presenting apps for consumption.

How does it differ from more classical virtualization and running on the bare tin see below


+----------+ +----------+ +----------+
| App      | | App      | | App      |
+----------+ +----------+ +----------+
| App dep  | | App dep  | | App dep  |
+----------+ +----------+ +----------+
| Guest OS | | Guest OS | | Guest OS |
+----------+ +----------+ +----------+
| Host OS                            |
| Drivers                            |
| Server                             |
| Infrastructure                     |

Bare Tin

| Application       |
| App dependencies  |
| OS                |
| Drivers           |
| Server            |
| Infrastructure    |


+-------+ +-------+ +-------+ +-------+
|App    | |App    | |App    | |App    |
|       | |       | |       | |       |
|App dep| |App dep| |App dep| |App dep|
+-------+ +-------+ +-------+ +-------+
| Docker                              |
| Host OS                             |
| Drivers                             |
| Server                              |
| Infrastructure                      |

Building a Docker host

Using Alpine Linux we will create a Docker host, the choice of this OS is down to small footprint and ease of use, also I don’t have to mess with cloud-config files and SSH keys which is what you would look at doing in an enterprise environment so we will look at this another time linktoblogpost.

I am building this on My Rig so the hypervisor I have on hand is Hyper-V linktoblogpost below is the settings for my first docker host use a type 1 virtual machine with Hyper-V

Key takeaways 2 cores 4 GB and a hard-disk for sys and you can add one for data this is optional I also have it on an internal network which has an OPNSence firewall linktoblogpost as the gateway to the outside world but you can just do this on the default network I don’t like to.

Installing Apline

First, download the image the alpine Linux image for me this will be the virtual image there are many different types

yes it is that small that is a good thing in technology

now attached the Disk image to the disk drive and boot up you will be greeted with a login prompt default Username and password combo

and it says it there you can setup the system with the command: setup-alpine and work through this wizard

Take a note of the IP as you will need this in a minute when we need to login via SSH, for now, carry on with the wizard creating a password for the Root account keep this safe and secure

it will then ask about minors to download from number one is the main one but you can tell it to test them and select the fastest for you that takes time so for a lab will select 1 the Content Delivery Network

enable the SSH server default is fine

now the fun part setting up the disk we are going to use sda as sys you will notice disk space is large I haven’t changed the disk space as again this is a lab I don’t need to worry in a production environment you would have to be more careful

after setting the sys disk you will see that the wizard has stopped we can reboot make sure we remove the installation media or you will go back around this again. to reboot type the command reboot.

Creating a user for docker

Its best not to run docker in root user-space so we have to create a new user follow the guide below

addgroup -g 150 docker
adduser -G docker dockeras
apk update
apk add sudo

add under users

dockeras ALL=(ALL) ALL

to exit vi press Esc then type :wq

now we can ssh to the server ssh [email protected] where x is the IP address from earlier. if you need to find the IP address you can use the command ip a

From now on only configure this through SSH use some tool like Putty.

Installing Docker in Alpine.

To get docker we need to add the community repository for alpine that contains docker to do this we need to edit the repositories config file with the command

sudo vi /etc/apk/repositories

uncomment out the edge community repo

to exit vi and save press ESC then type :wq

we need to updated so it can pull the list in the repository and then add the application docker

sudo apk update
apk policy docker
sudo apk add docker
sudo apk add docker-compose

not done yet we need to add Docker to the startup programs when alpine boot-up

sudo rc-update add docker boot

now lets start the docker service and check its status

sudo service docker start
service docker status

let’s run our first container it is the first container every one runs and makes sure everything is working as intended

docker run --rm hello-world

Done we have successfully installed Docker we can now use docker and docker-compose. Winning now go look at docker hub

Leave a Reply

Your email address will not be published.