Creating Linux Test Environments using Docker
Authors: Arun Ramanathan & Pavankumar Mudalagi
Assume you need to deploy 10 SLES 11 SP3 machines. The most common run of the mill way we use is to deploy 10 Linux servers in an ESX host machine or Virtual Box or XEN server. The only drawback is we need to clone and install these Linux desktops at least 9 times which is time consuming. Do we have an alternative?
Yes we do!
First install your Base Linux Machine. I installed openSUSE 13.2 (Harlequin) (x86_64)
Deploying SLES 11 SP3 Container with Docker
Step 1: Download SLES 11 SP3 images.
- Signup in https://hub.docker.com/
- Search for SLES 11 SP3
- Select your image, we selected gbeutner/sles-11-sp3-x86_64 since it had large number of pull.
- Above Image can be pulled from Docker’s central index at http://index.docker.io using the command:
# docker pull gbeutner/sles-11-sp3-x86_64
# docker images
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
gbeutner/sles-11-sp3-x86_64 latest 22de129c1cdd 10 months ago 193.1 MB
Step 2: Run this Image with an IMAGE ID “22de129c1cdd” :
#docker run -i -t 22de129c1cdd /bin/bash
ebf803aaabe9:/ # ----> it will open a new bash prompt
Step 3: Install and configure all required software in this image. In my case I needed Go Programming language.
Step 4: In a new Terminal of OpenSUSE 13.2, commit the container.
ebf803aaabe9:/# mkdir -p /home/Golang ; cd /home/Golang
ebf803aaabe9:/home/Golang # scp fa.ke.ad.dr:/home/Golang/go1.4.2.linux-amd64.tar.gz /home/Golang/
ebf803aaabe9:/home/Golang # tar -xvzf go1.4.2.linux-amd64.tar.gz
Get Container ID.
# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
ebf803aaabe9 22de129c1cdd:latest "/bin/bash" 9 minutes ago Up 9 minutes reverent_blackwell
Commit the image using Container ID.
# docker commit ebf803aaabe9
Step 5: Clone and Run the images.
First, get the list of images
# docker images
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
<none> <none> 9d36165e91df 2 minutes ago 485 MB
gbeutner/sles-11-sp3-x86_64 latest 22de129c1cdd 10 months ago 193.1 MB
In 10 new SSH terminals, run the latest Image with Image ID “9d36165e91df” to get 10 unique SLES 11 machine.
# docker run -i -t 9d36165e91df /bin/bash
To see list of Running Containers
# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
62382eed12af 9d36165e91df:latest "/bin/bash" 14 seconds ago Up 14 seconds adoring_mayer
To close a Running Container say with Container ID “62382eed12af“
62382eed12af:/ # exit
Exit
Conclusion: If you want a quicker way to deploy Linux / Windows machines, it’s time to move to Docker. You can save many man hours with it!
References:
https://docs.docker.com/reference/commandline/cli/
https://www.suse.com/documentation/sles-12/singlehtml/dockerquick/dockerquick.html
No comments yet