Category Archives: Development

Docker

Reference

Commanddescription
systemctl start docker
systemctl status docker
systemctl stop docker
docker info
docker version
start docker
view docker process status
stop docker
view docker info
view docker version
docker images
docker image ls
docker search ubuntu
docker pull ubuntu
docker rmi ubuntu
docker image rm
view image list
view image list ( > v1.13)
search for an image
download an image
delete an image
delete an image ( > v1.13)
docker ps -a
docker ps -l
docker container ls
docker container rm <cid>
docker rm <cid>
view running containers
view all containers
view containers ( > v1.13)
delete container with id <cid>
delete container with id <cid>
docker run imagename
docker run –name bla imagename
docker run -it ubuntu
docker start <cid>
docker stop <cid>
docker stop $(docker ps -q)
docker stats <cid>
docket top <cid>
docker kill<cid>
create and run a container
create and run a named container
create interactive session
start an existing container
stop a container
stop all running containers
view running stats of a container
view top stats of a container
kill a running container
docker attach <cid>
docker exec -it ubuntu bash
reconnect to a running container
Open a new terminal window

How to detach

How container was startedhow to detach
-t and -i is used to launch the containerctrl + P and then ctrl + Q
-t is used to launch the containerctrl + C
otherwisepkiill

Examples

sudo docker run --detach \
  --hostname gitlab.example.com \
  --publish 443:443 --publish 80:80 --publish 22:22 \
  --name gitlab \
  --restart always \
  --volume /srv/gitlab/config:/etc/gitlab \
  --volume /srv/gitlab/logs:/var/log/gitlab \
  --volume /srv/gitlab/data:/var/opt/gitlab \
  gitlab/gitlab-ce:latest

References:

enable cors (standard ee)

Simply create the filter:

import java.io.IOException;
 import javax.ws.rs.container.ContainerRequestContext;
 import javax.ws.rs.container.ContainerResponseContext;
 import javax.ws.rs.container.ContainerResponseFilter;
 import javax.ws.rs.ext.Provider;
 @Provider
 public class RestResponseFilter implements ContainerResponseFilter{
 @Override
     public void filter(ContainerRequestContext requestContext, ContainerResponseContext responseContext) throws IOException{
         responseContext.getHeaders().putSingle("Access-Control-Allow-Origin", "*");
         responseContext.getHeaders().putSingle("Access-Control-Allow-Credentials", "true");
         responseContext.getHeaders().putSingle("Access-Control-Allow-Methods", "GET, POST, DELETE, PUT");
         responseContext.getHeaders().putSingle("Access-Control-Allow-Headers", "Content-Type, Accept");
     }
 }

References

ElasticSearch notes

Resources:

For installation check this url. (DEB page link)

Default cluster configuration:

cluster name elasticsearch

Start/stop service

SysV:

sudo -i service elasticsearch start
sudo -i service elasticsearch stop

Systemd (read more here):

sudo systemctl start elasticsearch.service
sudo systemctl stop elasticsearch.service
sudo systemctl restart elasticsearch.service
sudo systemctl status elasticsearch.service

sudo systemctl enable elasticsearch.service
sudo systemctl disable elasticsearch.service

sudo systemctl start kibana.service
sudo systemctl stop kibana.service

Version and log information

view log sudo journalctl -f
view log for service sudo journalctl –unit elasticsearch

Cluster information

Health curl -X GET “localhost:9200/_cat/health?v”
Indices curl “localhost:9200/_cat/indices?v”

Index management

index stats curl -X GET “localhost:9200/mydb/_stats?pretty”
get all documents curl -X GET “localhost:9200/_search” -H ‘Content-Type: application/json’ -d'{ “query”: { “match_all”: {} } }’
get all documents http://localhost:9200/mydb/_search
count all documents curl -X GET “localhost:9200/mydb/_count”
count all documents http://localhost:9200/mydb/_count
delete index entries curl -XPOST ‘localhost:9200/mydb/_doc/_delete_by_query?conflicts=proceed’ -H’Content-Type: application/json’ -d’ { “query”: { “match_all”: {} }}’
delete index curl -X DELETE “localhost:9200/mydb”

sd

xbindkeys configuration

Setup:

  1. mouse side button 8 sends Enter
  2. mouse side button 9 sends alt+left
  3. tilde sends ctrl+w

 

Installation:

sudo apt-get install xautomation
sudo apt-get install x11-utils
sudo apt-get install xdotool

To find the keycodes run xev or xbindkeys -k:

xev
xbindkeys - k

Here is a sample script:

#send alt+left on side button 9
"xte 'keydown Alt_L' 'key Left' 'keyup Alt_L'"
   b:9

#send Enter on side button 8
"xte 'key Return'"
   b:8

#Using keycodes
"xte 'keydown Control_L' 'key w' 'keyup Control_L'"
    grave + release

 

References: