Thursday, June 4, 2015

Microservices using AWS Beanstalk or ECS for Docker


https://registry.hub.docker.com/u/progrium/consul/

Docker Compose

Docker commands

getting a shell

$ docker exec -lt tomcat bash
$ winpty docker exec -lt tomcat bash

Docker Installation on RHEL 7.2

201705 update
   77  sudo yum install docker
   78  sudo yum install -y yum-utils
   79  sudo yum-config-manager     --add-repo     https://download.docker.com/linux/centos/docker-ce.repo
   80  sudo yum-config-manager --enable docker-ce-edge
   81  sudo yum makecache fast
   83  sudo yum install docker-ce
   84  sudo systemctl start docker
   85  sudo docker run hello-world
   86  docker ps



https://blog.docker.com/2015/07/new-apt-and-yum-repos/
We are moving to microservices.  This architectural change will involve partitioning our code along service lines that will also break up our current WAR based deployments.  Part of this exercise accomplished via a move to Docker containers and Kubernetes as the orchestration and auto scaling engine.  The docker containers will live in our current OpenStack private cloud.
Installing Docker
Install docker on RHEL 7.2  (7.x supported)
https://docs.docker.com/engine/installation/rhel/
Set Alcatel-Lucent proxy
https://docs.docker.com/engine/articles/systemd/#http-proxy
Installing on a RHEL 7.2 metal or VM instance
sudo su
mkdir /etc/systemd/system/docker.service.d
vi /etc/systemd/system/docker.service.d/http-proxy.conf
[Service]
Environment="HTTP_PROXY=http://global.proxy:80"
vi /etc/yum.repos.d/docker.repo
[dockerrepo]
name=Docker Repository
enabled=1
gpgcheck=1
yum install docker-engine
service docker start

Verify container operation

sudo docker run hello-world


A more realistic demo would be to create an empty fedora (RHEL compatible) vm and enter a shell on the VM.  Open a 2nd cmd window and type "docker events" to listen in on container creation/destruction - in the case where you "exit" from the container.
in a 1st terminal
obrienlabs-mbp15:~ michaelobrien$ ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no root@192.168.121.133
docker events
and in a 2nd terminal
docker run --rm -ti fedora:latest /bin/bash
[root@rhel72virtual stack]# docker run --rm -ti fedora:latest /bin/bash 
Unable to find image 'fedora:latest' locally 
latest: Pulling from library/fedora
369aca82a5c0: Pull complete 
3fc68076e184: Pull complete 
Digest: sha256:7d916d5d3ab2d92147e515d3c09cb47a0431e2fff9d550fd9bcc4fed379af9ea
Status: Downloaded newer image for fedora:latest
[root@e7de408df84b /]# ls
bin  boot  dev  etc  home  lib  lib64  lost+found  media  mnt  opt  proc  root  run  sbin  srv  sys  tmp  usr  var
[root@e7de408df84b /]# df
Filesystem                                                                                      1K-blocks    Used Available Use% Mounted on
/dev/mapper/docker-253:0-21844-e7de408df84b187a90e298609097a27dd1eeda0bea346278d3ebff2343e98705 104805376  255332 104550044   1% /
[root@e7de408df84b /]# exit
 exit
[root@rhel72virtual stack]# 
in the "docker events" terminal (note: the hex is different because I tested with a 2nd instance
[root@rhel72virtual ~]# docker events
2016-01-05T17:04:37.916688150-05:00 b633da3a3e55457cb7b81d75f0516f07da065d211b07573b4ae79d5762322f4a: (from fedora:latest) create
2016-01-05T17:04:37.951828323-05:00 b633da3a3e55457cb7b81d75f0516f07da065d211b07573b4ae79d5762322f4a: (from fedora:latest) attach
2016-01-05T17:04:38.006487503-05:00 b633da3a3e55457cb7b81d75f0516f07da065d211b07573b4ae79d5762322f4a: (from fedora:latest) start
2016-01-05T17:04:38.147536237-05:00 b633da3a3e55457cb7b81d75f0516f07da065d211b07573b4ae79d5762322f4a: (from fedora:latest) resize
2016-01-05T17:04:56.375942258-05:00 b633da3a3e55457cb7b81d75f0516f07da065d211b07573b4ae79d5762322f4a: (from fedora:latest) die
2016-01-05T17:04:58.110736214-05:00 b633da3a3e55457cb7b81d75f0516f07da065d211b07573b4ae79d5762322f4a: (from fedora:latest) destroy

Docker Installation on Ubuntu 14.04



Docker Installation on OSX 10.11


The following tutorial is very good
https://docs.docker.com/installation/mac/
bash-3.2$ docker run -d -P --name web nginx
bash-3.2$ docker ps
CONTAINER ID        IMAGE               COMMAND                CREATED             STATUS              PORTS                                           NAMES
15abd6456e7e        nginx:latest        "nginx -g 'daemon of   56 seconds ago      Up 56 seconds       0.0.0.0:32769->80/tcp, 0.0.0.0:32768->443/tcp   web      
bash-3.2$ docker port web
bash-3.2$ boot2docker ip
http://192.168.59.103:32769
bash-3.2$ docker run -d -P -v $HOME/site:/usr/share/nginx/html --name mysite nginx

e6b5188e2dba301ce9b041b472dc9dc79272beae87d9840c82052ddd6735e614

bash-3.2$ docker ps
CONTAINER ID        IMAGE               COMMAND                CREATED             STATUS              PORTS                                           NAMES
34e4e4239aa7        nginx:latest        "nginx -g 'daemon of   6 minutes ago       Up 6 minutes        0.0.0.0:32777->80/tcp, 0.0.0.0:32776->443/tcp   mysite              
15abd6456e7e        nginx:latest        "nginx -g 'daemon of   32 minutes ago      Up 32 minutes       0.0.0.0:32769->80/tcp, 0.0.0.0:32768->443/tcp   web       

bash-3.2$ docker stop mysite

bash-3.2$ docker rm mysite


Install Docker Compose

[root@biomos40 openstack]# curl -L https://github.com/docker/compose/releases/download/1.5.2/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   600    0   600    0     0   1183      0 --:--:-- --:--:-- --:--:--  1183
100 7739k  100 7739k    0     0  1392k      0  0:00:05  0:00:05 --:--:-- 1690k
[root@biomos40 openstack]# chmod +x /usr/local/bin/docker-compose
do command completion
curl -L https://github.com/docker/compose/releases/download/1.5.2/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose
[openstack@biomos40 ~]$ docker-compose --version
docker-compose version 1.5.2, build 7240ff3




Notes



Links
https://docs.docker.com/articles/basics/

No comments:

Total Pageviews

Followers