Install CentOS7 Minimal 64-bit as a virtual machine.
I am using VMware Player as the hypervisor.
Create a new virtual machine.
Install CentOS onto the virtual machine.
You only need to click ‘Done’ for the ‘Installation Destination’ then ‘Begin Installation’.
It starts installing.
You can set a ‘root’ password here.
I just use ‘password’
Once installed you’ll be at the command line.
Login using username ‘root’ and password ‘password’
We must configure our Internet connection first.
Edit a connection
Enable ‘Automatically connect’, by pressing spacebar
systemctl restart network
We should update CentOS
yum -y update
Now we install Docker
yum -y install docker docker-registry
systemctl enable docker.service
systemctl start docker
Check if Docker is working
systemctl status docker.service
You should see in green text ‘active (running)’
In order to run an application in Docker you must make it into an image.
You can get ready-made images from:
Also running each image requires different commands which will be listed here
You can try running an image, by using the following command, but it won’t work, since we have no images downloaded.
ABC in this context would be the name of an image
sudo docker run ABC
Check what images we have
We have none
We will download Dell’s LAMP image
docker pull dell/lamp
Check what images we have again, now we have one
Now run Dell’s LAMP image in Docker
sudo docker run -d -p 8080:80 dell/lamp
Now we test if the LAMP is working, by trying to get a message to display in the command line first then a browser
If one browser doesn’t work, try another
If we get a ‘Hello World’ message, we know it works
yum -y install net-tools
Note down your IP address
Should be the 2nd network adapter
With IP address 192.168.***.***
Now in a browser type:
It should display the Dell symbol
MySQL Server version: 5.5.43-0ubuntu0.14.04.1
Now we create a image and load it into Docker
Make a directory and put it in there
Navigate to it
We now create some kind of script that will pull
a docker image of Ubuntu from the Docker servers
so we can load it in Docker
It will also include Ruby with the Ubuntu install
Press INSERT to type
Press ESC to stop typing
Use this to save and exit:
# this allows for comments
Type this into the script:
# Dockerfile build ubuntu with Ruby
RUN apt-get -qq update
RUN apt-get -qqy install ruby ruby-dev
RUN gem install sinatra
This builds the image in the script
Then runs it
sudo docker build -t=”ouruser/sinatra:v2″ .
sudo docker run -t -i ouruser/sinatra:v2 /bin/bash
After doing that, we are now inside Ubuntu, which is inside CentOS
We will write a Ruby script to test if the Ubuntu is working OK
Write this in the script:
puts “Hello World”;
Now run the script
To exit from Ubuntu, back to CentOS
Press Ctrl P+Q
That completes this demonstration!