Monday, March 21, 2016

docker survival kit

on Ubuntu 14.04:

-------------- docker service itself
service docker start

-------------- install
sudo bash
vi /etc/apt/sources.list.d/docker.list
deb https://apt.dockerproject.org/repo ubuntu-trusty main

apt-get update
you may have to do this with the associated keys if the former doesn't work
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys F76221572C52609D

apt-get -y install docker.io
apt-get install docker-engine
(don't do    "apt-get install docker")

ln -sf /usr/bin/docker /usr/local/bin/docker
sed -i '$acomplete -F _docker docker' /etc/bash_completion.d/docker.io
or
sed -i '$acomplete -F _docker docker' /etc/bash_completion.d/docker
(depends which works)
  • start docker daemon
    • $ sudo service docker start
docker -v    (should be at least 1.12)
docker version
docker info
docker pull hello-world
docker run -it  hello-world

docker pull centos:6.6
docker run -it centos:6.6 /bin/bash

sudo docker images -a


------------- Main
  • Run but exits right away with an error. Still, creates a container.
    • docker run ubuntu
  • Run and keeps an interactive session
    • docker run -it ubuntu /bin/bash
    • docker run -it alpine /bin/sh
    • sudo docker run -it {repository_name}:{tag} /bin/bash
  • Execute in a running container:
    • “docker exec -it 7b33f4ed03a7 /bin/bash” (or /bin/sh on alpine)
    • sudo docker exec -it $(sudo docker ps -l -q) env
    • with root privilege in the docker bash session
      • sudo docker exec -it --user root 58d3daf3a0dd /bin/bash
  • Restart an existing container to continue working in it
    • docker start 912ccdad8380
    • then docker exec -it 912ccdad8380 /bin/bash

  • To build a container from a Dockerfile:
    • sudo docker build {Dockerfile_path}
------------- 
docker rename 7d8b244480a2 my_django____4         (rename a container)
docker commit 7d8b244480a2  bob/hello_django:version2  (commit a new image from a running container)

docker save -o /home/bob/bob-hello-django-version4.tar  bob/hello_django:version2

docker load -i bob-hello-django-version2.tar

-------------
- "ls /etc/*release"  to know the container OS.
  • remove all containers and clear cache (do not remove images...)
    • docker rm $(docker ps -a -q) && docker ps -a | cut -c-12 | xargs docker rm
  • remove a specific image 
    • sudo docker rmi -f 4f8eceb5cb78
  • WARNING WATCH OUT: remove all images
    • docker rmi $(docker images -q) -f
  • ignore container entrypoint:
    • docker run -it --entrypoint=/bin/bash michal/hello_django_srp:version5
------------- problem 1
Docker version 1.6.2, build 7c8fca2

> docker save -o /tmp/docker1.tar  michal/hello_django_srp:version6

FATA[0000] Error response from daemon: could not find image: no such id:  michal/hello_django_srp:version6 
--> there are two spaces before "michal" and docker is not robust to this
------------- static IP address
docker network create --subnet=172.18.0.0/16 mynet18 docker run --net mynet18 --ip 172.18.0.22 -it ubuntu:14.04 bash
------------- bind volume mount (you need data from the host machine)
docker run -it -v /home/lee/tmp/docker-bind:/opt/container-path bob/solr_6_6:v7

otherwise, you can simply copy from the host to the container:
docker cp ./syn_acc.txt dfccf5a493c3:/usr/share/elasticsearch/config/resources/v1_02/
------------- other commands
docker ps --last 5
docker inspect 7832d56ddf56

docker logs 7fbc2e820d4c 

docker run -it -p 8580:8080 bob/my-jetty:v1 (port matching)
-------------- when using rancher Desktop
 You can check index creation by doing
"watch docker ps" (get docker port number)

  CONTAINER ID   IMAGE                                                                    COMMAND                          PORTS                                                                                                                                NAMES
d229f1ce7bc2 localhost/testcontainers/m3ancimbepv8mj4a:latest "/bin/tini -- /usr/l…" 0.0.0.0:49196->9200/tcp, :::49196->9200/tcp, 0.0.0.0:49195->9300/tcp, :::49195->9300 tcp sleepy_galois
5d89fb8008f2 testcontainers/ryuk:0.11.0 "/bin/ryuk" 0.0.0.0:49194->8080/tcp, :::49194->8080/tcp testcontainers-ryuk-5cede40f-ba07-41f2-a324-6f155ae34fa8


.
.

Sunday, March 20, 2016

strange colors on vlc / Windows 7 / need nvidia driver



http://fr.download.nvidia.com/Windows/341.92/341.92-notebook-win8-win7-64bit-international.exe


Tuesday, March 15, 2016

Debugging Tomcat remotely using JMX


Start the tomcat as follows
./start.sh -d -p 8001 -j -m 9001 -h 10.2.14.2

From Eclipse:
  - debug configurations
  - "Remote Java application"
  - "connect" tab
    . Host running the tomcat
    . Port: 8001

Saturday, January 23, 2016

Java Web Services


  • Specifications
    • JAX-RS    (Java API for RESTful Web Services)
      • implementations:
        • Jersey
        • Apache CXF
        • RESTEasy (JBoss implementation)
    • JAX-WS     (Java API for XML Web Services)
      • implementations:
        • part of the J2EE platform
        • Apache CXF
        • Axis2
      • based on SOAP
  • Implementations
    • Jersey
    • Apache CXF
      • https://cxf.apache.org/
      • WS framework
      • JAX-WS and  JAX-RS  front end APIs support
      • mainly SOAP: good for client-side WSDL services
      • can speak with SOAP, XML/HTTP, RESTful HTTP

Tuesday, January 5, 2016

PostgreSQL / Postgres / Postgre


lg@lgstage11:~$ psql -U user -p 5432 mydb

mydb=> \dt

 Liste des relations
 Schéma |       Nom       | Type  | Propriétaire
--------+-----------------+-------+--------------
 public | shop_c           | table | user
 public | shop_ean       | table | user
(2 lignes)

mydb=> \x      -> formatting

select * from shop_e limit 10;

service postgresql stop
service postgresql start

psql -U user --password
if this complains that the user doesn't have a database, you can do it another way:
postgre@machine:  createuser search
postgre@machine:  createdb search

\copy (select lt.image.lt_kimage_id from lt.image LIMIT 100000) To '/tmp/test.csv';

DELETE FROM image WHERE image_id IN (select image.image_id from image INNER JOIN keyword ON image_id = keyword.image_id WHERE keyword.keyword LIKE '%_dead' ORDER BY image_id LIMIT 200000);

-- if "psql" doesn't work, do this first:
    su - postgres
 https://gist.github.com/Kartones/dd3ff5ec5ea238d4c546
.
.

    Thursday, November 26, 2015

    Some Python packages


    yum install python27

    ---- install numpy
    yum install python27-pip python27-devel parallel
    cd /usr/bin
    ln -s pip2.7 pip
    pip install --upgrade pip
    pip install requests solrpy
    yum install gcc
    pip install numpy

    ---- numpy, scipy on ubuntu
    yum install python-pip python-dev build-essential
    yum install libatlas-base-dev gfortran
    pip install numpy scipy

    ---- scipy on centOS
    yum install lapack-devel
    pip install scipy

    ---- Install pip
    yum install python-pip
    if you have an error like: "urllib3/util/ssl_.py:90: InsecurePlatformWarning" do:
    sudo yum remove python-openssl

    ---- look for a package:
    pip search requests |grep requests
    ---- see if it is installed
    pip show requests
    ---- see all installed
    pip freeze

    ---- MySQL
    pip install MySQL-python       didn't work right away. I had to do this

    yum search all MySQL
    yum install MySQL-client
    yum install MySQL-devel
    yum install MySQL-python27

    ---- image hash
    pip install ImageHash

    --- look for local Python package
    pip list | grep cv

    --- my-virtualenv
           (if  version < Python 3.3:    virtualenv my-virtualenv -p /usr/bin/python)
           /opt/homebrew/bin/python3.10 -m venv my-virtualenv
      my-virtualenv$ source bin/activate
                --- important: use pip from the virtualenv ---
                --- start by doing "pip install --upgrade pip"
      (my-virtualenv) lee@mycomp:~/python/flask/my-virtualenv$ deactivate

    (my-virtualenv) lee@G10054 scripts % which python3
    /Users/lee/dev/es/src/main/scripts/my-virtualenv/bin/python3
    .
    .

    Sunday, October 18, 2015

    Postfix survival kit (SMTP server)

    http://www.postfix.org/

    config in:
    /etc/postfix/main.cf