Labels

Thursday, March 8, 2018

Create docker image for Kubernetes

The Persistent Application Client Container (PACC) is a Docker-based container image that includes a container-optimized MapR client

1) Create docker repo

wget https://download.docker.com/linux/centos/docker-ce.repo -O /etc/yum.repos.d/docker-ce.repo

[root@vn1 yum.repos.d]# wget https://download.docker.com/linux/centos/docker-ce.repo -O /etc/yum.repos.d/docker-ce.repo
--2018-03-06 09:31:33--  https://download.docker.com/linux/centos/docker-ce.repo
Resolving download.docker.com (download.docker.com)... 54.192.146.111, 54.192.146.242, 54.192.146.119, ...
Connecting to download.docker.com (download.docker.com)|54.192.146.111|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 2424 (2.4K) [binary/octet-stream]
Saving to: ‘/etc/yum.repos.d/docker-ce.repo’

100%[===================================================================================>] 2,424       --.-K/s   in 0s

2018-03-06 09:31:33 (306 MB/s) - ‘/etc/yum.repos.d/docker-ce.repo’ saved [2424/2424]


2) Install Docker

yum -y install docker-ce

[root@vn1 yum.repos.d]# yum -y install docker-ce
Loaded plugins: fastestmirror
base                                                                                                  | 3.6 kB  00:00:00
docker-ce-stable                                                                                      | 2.9 kB  00:00:00
extras                                                                                                | 3.4 kB  00:00:00
maprecosystem                                                                                         | 1.4 kB  00:00:00
maprtech                                                                                              | 1.4 kB  00:00:00
updates                                                                                               | 3.4 kB  00:00:00
Loading mirror speeds from cached hostfile
 * base: mirror.it.ubc.ca
 * extras: mirror.its.sfu.ca
 * updates: muug.ca
Resolving Dependencies
--> Running transaction check
---> Package docker-ce.x86_64 0:17.12.1.ce-1.el7.centos will be installed
--> Finished Dependency Resolution

Dependencies Resolved

=============================================================================================================================
 Package                  Arch                  Version                                Repository                       Size
=============================================================================================================================
Installing:
 docker-ce                x86_64                17.12.1.ce-1.el7.centos                docker-ce-stable                 30 M

Transaction Summary
=============================================================================================================================
Install  1 Package

Total download size: 30 M
Installed size: 123 M
Downloading packages:
docker-ce-17.12.1.ce-1.el7.centos.x86_64.rpm                                                          |  30 MB  00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : docker-ce-17.12.1.ce-1.el7.centos.x86_64                                                                  1/1
  Verifying  : docker-ce-17.12.1.ce-1.el7.centos.x86_64                                                                  1/1

Installed:
  docker-ce.x86_64 0:17.12.1.ce-1.el7.centos

Complete!


3) Start Docker service and validate the status of docker if it's up and running

systemctl start docker.service
systemctl status docker.service

[root@vn1 yum.repos.d]# systemctl start docker.service
[root@vn1 yum.repos.d]# systemctl status docker.service
● docker.service - Docker Application Container Engine
   Loaded: loaded (/usr/lib/systemd/system/docker.service; disabled; vendor preset: disabled)
   Active: active (running) since Tue 2018-03-06 09:33:20 PST; 4s ago
     Docs: https://docs.docker.com
 Main PID: 22476 (dockerd)
   Memory: 21.5M
   CGroup: /system.slice/docker.service
           ├─22476 /usr/bin/dockerd
           └─22485 docker-containerd --config /var/run/docker/containerd/containerd.toml

Mar 06 09:33:19 vn1 dockerd[22476]: time="2018-03-06T09:33:19.537883200-08:00" level=warning msg="devmapper: Base device already exists and has filesyst... ignored."
Mar 06 09:33:19 vn1 dockerd[22476]: time="2018-03-06T09:33:19.554866674-08:00" level=info msg="[graphdriver] using prior storage driver: devicemapper"
Mar 06 09:33:19 vn1 dockerd[22476]: time="2018-03-06T09:33:19.608849366-08:00" level=info msg="Graph migration to content-addressability took 0.00 seconds"
Mar 06 09:33:19 vn1 dockerd[22476]: time="2018-03-06T09:33:19.611058945-08:00" level=info msg="Loading containers: start."
Mar 06 09:33:19 vn1 dockerd[22476]: time="2018-03-06T09:33:19.889925019-08:00" level=info msg="Default bridge (docker0) is assigned with an IP address 1...P address"
Mar 06 09:33:19 vn1 dockerd[22476]: time="2018-03-06T09:33:19.996413727-08:00" level=info msg="Loading containers: done."
Mar 06 09:33:20 vn1 dockerd[22476]: time="2018-03-06T09:33:20.036646534-08:00" level=info msg="Docker daemon" commit=7390fc6 graphdriver(s)=devicemapper...17.12.1-ce
Mar 06 09:33:20 vn1 dockerd[22476]: time="2018-03-06T09:33:20.036826920-08:00" level=info msg="Daemon has completed initialization"
Mar 06 09:33:20 vn1 dockerd[22476]: time="2018-03-06T09:33:20.050498082-08:00" level=info msg="API listen on /var/run/docker.sock"
Mar 06 09:33:20 vn1 systemd[1]: Started Docker Application Container Engine.
Hint: Some lines were ellipsized, use -l to show in full.


4) Download the mapr-setup.sh script from mapr.com to a Linux platform where Docker 1.12.5 or later is installed

wget http://package.mapr.com/releases/installer/mapr-setup.sh -P /tmp

[root@vn1 yum.repos.d]# wget http://package.mapr.com/releases/installer/mapr-setup.sh -P /tmp
--2018-03-06 09:34:03--  http://package.mapr.com/releases/installer/mapr-setup.sh
Resolving package.mapr.com (package.mapr.com)... 54.192.146.174, 54.192.146.204, 54.192.146.206, ...
Connecting to package.mapr.com (package.mapr.com)|54.192.146.174|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 113436 (111K) [text/x-sh]
Saving to: ‘/tmp/mapr-setup.sh’

100%[===========================================================================================================================>] 113,436     --.-K/s   in 0.01s

2018-03-06 09:34:03 (7.45 MB/s) - ‘/tmp/mapr-setup.sh’ saved [113436/113436]



5) Execute the script to create an docker image

/tmp/mapr-setup.sh docker client

.........
......
Edit '/root/docker_images/client/mapr-docker-client.sh' to set MAPR_CLUSTER and MAPR_CLDB_HOSTS and then execute it to start the container
.....


6) Edit the file /root/docker_images/client/mapr-docker-client.sh and update the following properties based on the your cluster set up.

MAPR_CLUSTER=SixO
MAPR_CLDB_HOSTS=vn1


7) Execute mapr-docker-client.sh file to start the container.

/root/docker_images/client/mapr-docker-client.sh


Testing for cluster user account...

Enter MapR cluster user name: root
 ...Success

Configuring MapR client ( -c -C vn1 -N SixO)...

create /opt/mapr/conf/conf.old
CLDB node list: vn1:7222
Zookeeper node list:
Cluster conf:  /opt/mapr/conf/mapr-clusters.conf
Log can be found at:  /opt/mapr/logs/configure.log

Note: No Hadoop configuration with this configure script.

...Success

Warning: Unable to determine $DRILL_HOME
Warning: Unable to determine $DRILL_HOME




1) [root@vn1 ~]# docker ps -a
CONTAINER ID        IMAGE                               COMMAND                  CREATED             STATUS              PORTS               NAMES
ff6e4dbfca46        maprtech/pacc:6.0.0_4.0.0_centos7   "/opt/mapr/installer…"   40 seconds ago      Up 38 seconds                           loving_curran


2)  docker inspect <containerId>
docker inspect ff6e4dbfca46

3) [root@vn1 ~]# docker images
REPOSITORY          TAG                   IMAGE ID            CREATED             SIZE
maprtech/pacc       6.0.0_4.0.0_centos7   cc8e677d8e52        6 minutes ago       624MB
centos              centos7               2d194b392dd1        17 hours ago        195MB



List of docker commands :

[root@vn1 ~]# docker

Usage:  docker COMMAND

A self-sufficient runtime for containers

Options:
      --config string      Location of client config files (default "/root/.docker")
  -D, --debug              Enable debug mode
  -H, --host list          Daemon socket(s) to connect to
  -l, --log-level string   Set the logging level ("debug"|"info"|"warn"|"error"|"fatal") (default "info")
      --tls                Use TLS; implied by --tlsverify
      --tlscacert string   Trust certs signed only by this CA (default "/root/.docker/ca.pem")
      --tlscert string     Path to TLS certificate file (default "/root/.docker/cert.pem")
      --tlskey string      Path to TLS key file (default "/root/.docker/key.pem")
      --tlsverify          Use TLS and verify the remote
  -v, --version            Print version information and quit

Management Commands:
  config      Manage Docker configs
  container   Manage containers
  image       Manage images
  network     Manage networks
  node        Manage Swarm nodes
  plugin      Manage plugins
  secret      Manage Docker secrets
  service     Manage services
  stack       Manage Docker stacks
  swarm       Manage Swarm
  system      Manage Docker
  trust       Manage trust on Docker images (experimental)
  volume      Manage volumes

Commands:
  attach      Attach local standard input, output, and error streams to a running container
  build       Build an image from a Dockerfile
  commit      Create a new image from a container's changes
  cp          Copy files/folders between a container and the local filesystem
  create      Create a new container
  diff        Inspect changes to files or directories on a container's filesystem
  events      Get real time events from the server
  exec        Run a command in a running container
  export      Export a container's filesystem as a tar archive
  history     Show the history of an image
  images      List images
  import      Import the contents from a tarball to create a filesystem image
  info        Display system-wide information
  inspect     Return low-level information on Docker objects
  kill        Kill one or more running containers
  load        Load an image from a tar archive or STDIN
  login       Log in to a Docker registry
  logout      Log out from a Docker registry
  logs        Fetch the logs of a container
  pause       Pause all processes within one or more containers
  port        List port mappings or a specific mapping for the container
  ps          List containers
  pull        Pull an image or a repository from a registry
  push        Push an image or a repository to a registry
  rename      Rename a container
  restart     Restart one or more containers
  rm          Remove one or more containers
  rmi         Remove one or more images
  run         Run a command in a new container
  save        Save one or more images to a tar archive (streamed to STDOUT by default)
  search      Search the Docker Hub for images
  start       Start one or more stopped containers
  stats       Display a live stream of container(s) resource usage statistics
  stop        Stop one or more running containers
  tag         Create a tag TARGET_IMAGE that refers to SOURCE_IMAGE
  top         Display the running processes of a container
  unpause     Unpause all processes within one or more containers
  update      Update configuration of one or more containers
  version     Show the Docker version information
  wait        Block until one or more containers stop, then print their exit codes

Run 'docker COMMAND --help' for more information on a command.
Posted by Vinayak Meghraj at 1:43 PM 
Email This
BlogThis!
Share to Twitter
Share to Facebook
Share to Pinterest

Labels: k8s

3 comments: