Sunteți pe pagina 1din 10

Oracle Compute Cloud Service

- Confidential -

LAB 6
Oracle Compute
Cloud Workshop

Oracle Platform Technology


Solutions
Deploying Docker on Oracle Compute

Page 1 of 10
Oracle Compute Cloud Service
- Confidential -

Deploying Docker on Oracle Compute

Contents

................................................................................................
Purpose................................................................ ........................................ 3
Pre-requisite ................................
................................................................................................................................
................................ 3
Docker Lightweight Virtualization Containers ................................................................
........................................... 3
Install Docker Engine ................................
................................................................................................
................................................. 4
Run a docker image ................................
................................................................................................
.................................................... 6
Decide on a base image to use. Example: oraclelinux:6.6 .........................................................
......................... 6
Customizing a Container for Application Pr
Provisioning..............................................................
.............................. 8

Page 2 of 10
Oracle Compute Cloud Service
- Confidential -

Purpose

This document shows how to deploy docker on Oracle Compute Cloud Service.

Pre-requisite
A Virtual machine with OEL 6.6 should be running on Oracle IaaS with free ssh access.

Docker Lightweight Virtualization Containers


Docker containers are a lightweight virtualization technology for Linux. They provide isolation
from other applications and processes running on the same system but make system calls to the
same shared Linux kernel, similar to Linux LXC application containers. If you have a
background in Oracle Solaris, Docker containers might remind you of non non-global
global zones in
Oracle Solaris 10 or 11, which provide application isolation while sharing an underlying Oracle
Solaris operating system kernel. Docker containers have their own namespace, so they are fully
isolated from one anotherprocesses
processes running in one container can't see or impact processes
p
running in another. By default, each container gets its own networking stack, private network
interfaces, and IP address, and Docker creates a virtual bridge so containers can communicate.
Shared container access to the underlying Linux kernel is one reason why Docker containers are
deemed lightweight. When a Docker image is modified, the new container shares the same
binaries and libraries as the base container, which contributes to a smal
smaller
ler overall footprint.
footprint In
building and customizing contain
containers,
ers, Docker also uses the concept of layering, storing only
differences from the base container.

Page 3 of 10
Oracle Compute Cloud Service
- Confidential -

Install Docker Engine


(Reference - https://docs.docker.com/installation/oracle/
https://docs.docker.com/installation/oracle/)

1). Update the yum repository

$ sudo yum update

NOTE: Docker requires Unbreakable Enterprise Kernel >= 4.1 for the installation
installat

Just make sure you have the following things in your environment
environment.. If not please perform
the below steps to update the kernel to 4.1

a). Add UEKR4 in the file /etc/yum.repos.d/public


/etc/yum.repos.d/public-yum-ol6.repo
ol6.repo (make this change as
sudo. Please use "sudo vi /etc/yum.repos.d/public
/etc/yum.repos.d/public-yum-ol6.repo"
ol6.repo" to edit the file)
file

[ol6_UEKR4]
name=Latest Unbreakable Enterprise Kernel Release 4 for Oracle Linux
$releasever ($basearch)
yum.oracle.com/repo/OracleLinux/OL6/UEKR4/$basearch/
baseurl=http://public-yum.oracle.com/repo/OracleLinux/OL6/UEKR4/$basearch/
gpgkey=file:///etc/pki/rpm-
-gpg/RPM-GPG-KEY-oracle
gpgcheck=1
enabled=1

b). Enable oel_addons


[ol6_addons]
name=Oracle Linux $releasever Add ons ($basearch
($basearch)
baseurl=http://public-yum.oracle.com/repo/OracleLinux/OL6/addons/$basearch/
yum.oracle.com/repo/OracleLinux/OL6/addons/$basearch/
gpgkey=file:///etc/pki/rpm-
-gpg/RPM-GPG-KEY-oracle
gpgcheck=1
enabled=1

c). $ sudo yum update

2). Run the Docker installation script

$ curl -sSL
sSL https://get.docker.com/ | sh

This script adds the `docker.repo` repository and installs Docker.

3). Start the Docker daemon.

Page 4 of 10
Oracle Compute Cloud Service
- Confidential -

$ sudo service docker start

4). Verify docker is installed correctly by running a test image in a container.

$ sudo docker run hello-


-world
OUTPUT:
Unable to find image 'hello-world:latest'
world:latest' locally
latest: Pulling from hello-world
world
a8219747be10: Pull complete
91c95931e552: Already exists
hello-world:latest:
: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:aa03e5d0d5553b4c3473e89c8619cf79df368babd1.7.1cf5daeb82aab55838d
Status: Downloaded d newer image for hello
hello-world:latest
Hello from Docker.
This message shows that your installation appears to be working correctly
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
"hello-world" image from the Docker Hub.
(Assuming it was not already locally available.)
3. The Docker daemon created a new container from that image which runs the
executable that produces the output you are cu
currently reading.
4. The Docker daemon streamed that output to the Docker client, which sent it
to your terminal.

To try something more ambitious, you can run an Ubuntu container with:

$ docker run -it


it ubuntu bash

For more examples and ideas, visit:


sit:
http://docs.docker.com/userguide/

Page 5 of 10
Oracle Compute Cloud Service
- Confidential -

Run a docker image

Decide on a base image to use. Example: oraclelinux:6.6

The following commands pull the Oracle Linux 6 and Oracle Linux 7 images from the public
Docker Hub Registry, downloading them to the Oracle Linux host that's my test environment:

If no version number is specified in the docker pull command, then the latest available version is
pulled from the Docker Hub repository (for example, at the time of this publication, the latest
Oracle Linuxx version is actually Oracle Linux 7.1).

Oracle also publishes Docker container images for its verified version of MySQL on the public
Docker Hub Registry (note that docker pull mysql will pull the Ubuntu version of MySQL):

Page 6 of 10
Oracle Compute Cloud Service
- Confidential -

The command docker images lists the images available locally that I can run and customize

Customizing a Container for Application Provisioning

Specify a command to run against the image. Note: first time you try and use an image, Docker
will need to download it to your local machine.

Page 7 of 10
Oracle Compute Cloud Service
- Confidential -

$ docker run oraclelinux:6.6 echo hello world


OUTPUT:

Unable to find image 'oraclelinux:6.6' locally


Pulling repository oraclelinux
********* Pulling dependent layers
********: Download complete
hello world

$ docker run oraclelinux:6.6 echo


cho hello world
hello world

Each time you run an image, a docker container is automatically created.

Customizing a Container for Application Provisioning

Suppose that I want to provision multiple, identical web servers across multiple Linux servers in
my data center. Docker makes it easy to create a preconfigured, cookie
cookie-cutter
cutter environment in a
container image. I can then use this prebuilt image and deploy it across one or many Linux hosts.

To build a customized container image, I must first build a gue


guest
st container, install the web
server, and configure it to deliver web server content. I use the docker run command to run an
Oracle Linux 7 base container and execute a bash shell in the guest container:

The Docker Engine assigns an image ID to every running container instance. Because I used the
arguments -i and -t, the bash shell runs interactively, and the prompt reflects the first 12
characters (f85d55a6893f) of my running container's image ID. The --name argument specifies
a name for the running container instance. (If you choose not to enter a name, the Docker Engine
generates a random string that incorporates the name of a notable scientist, inventor, or developer

Page 8 of 10
Oracle Compute Cloud Service
- Confidential -

On the guest, I install the httpdd and perl RPM packages using yum, just as I would on any other
physical or virtual server. I also specify yum clean all to remove cache files that yum creates
during package installation, because that will ultimately save some space in the exported
container image:

Page 9 of 10
Oracle Compute Cloud Service
- Confidential -

At this point, I can configure content for the web server to display. For simplicity, I'll create a
basic opening page in the /var/www/html hierarchy on the guest:

Page 10 of 10

S-ar putea să vă placă și