bpeng / tickets

0 stars 0 forks source link

Docker #9

Open bpeng opened 8 years ago

bpeng commented 8 years ago
=== install/start docker === 
 1003  sudo yum install docker-io
      sudo systemctl start docker.service
 1021  sudo systemctl status docker.service

 1023   sudo docker run busybox echo hello world
=== run image container ===
 1027  sudo docker images

 1028  sudo docker run busybox echo 'hello'
 1029  time  sudo docker run busybox echo hello world
 1030  sudo docker run busybox ping google.com
 1031  sudo docker run -it ubuntu /bin/bash

 1035  sudo docker run -p 8000:80 atbacker/nginx-example
 1036  sudo docker run -p 8000:80 atbaker/nginx-example
 1037  sudo docker ps -a
 1039  sudo docker ps -a

 1040  time  sudo docker run docker.service

 1045  sudo docker ps -a

 1050  sudo systemctl status docker.service

 1052  sudo docker run -it ubuntu /bin/bash

 1056  sudo docker rm 88e617a00e73
 1057  sudo docker run -p 8000:80 atbaker/nginx-example
 1059  sudo docker run -d -p  8000:80 atbaker/nginx-example
 1060  sudo docker ps
 1061  sudo docker ps -a
 1063  sudo docker stop a67fb408f218
 1003  sudo yum install docker-io
 1004   sudo docker run busybox echo hello world
 1005  docker start
 1006  boot2docker start
 1007   sudo docker run busybox echo hello world
 1008  docker images
 1009  docker version
 1010  FATA[0000] Get http:///var/run/docker.sock/v1.16/version: dial unix /var/run/docker.sock: no such file or directory. Are you trying to connect to a TLS-enabled daemon without TLS?
 1011  boot2docker shellinit
 1012  $(boot2docker shellinit)
 1013  docker
 1015   sudo docker run busybox echo hello world
 1016  sudo systemctl start docker.service
 1017   sudo docker run busybox echo hello world
 1020   sudo docker run busybox echo hello world
 1021  sudo systemctl status docker.service
 1022  docker images
 1023   sudo docker run busybox echo hello world
 1024  docker
 1025  docker image
 1026  docker images
 1027  sudo docker images
 1028  sudo docker run busybox echo 'hello'
 1029  time  sudo docker run busybox echo hello world
 1030  sudo docker run busybox ping google.com
 1031  sudo docker run -it ubuntu /bin/bash
 1032  sudo docker run -it busybox /bin/sh 
 1034  sudo docker run -it busybox /bin/sh 
 1035  sudo docker run -p 8000:80 atbacker/nginx-example
 1036  sudo docker run -p 8000:80 atbaker/nginx-example
 1037  sudo docker ps -a
 1039  sudo docker ps -a
 1040  time  sudo docker run docker.service
 1041   sudo docker run docker.service
 1042   sudo docker run 60c976162915
 1045  sudo docker ps -a
 1046  sysctl status docker
 1050  sudo systemctl status docker.service
 1051  docker
 1052  sudo docker run -it ubuntu /bin/bash
 1053  sudo docker run -p 8000:80 atbaker/nginx-example
 1054  sudo docker images
 1055  sudo docker images -a
 1056  sudo docker rm 88e617a00e73
 1057  sudo docker run -p 8000:80 atbaker/nginx-example
 1058  sudo docker run -p -d  8000:80 atbaker/nginx-example
 1059  sudo docker run -d -p  8000:80 atbaker/nginx-example
 1060  sudo docker ps
 1061  sudo docker ps -a
 1062  sudo docker ps
 1063  sudo docker stop a67fb408f218
 1064  sudo docker ps
 1065  sudo docker rm  a67fb408f218
 1066  sudo docker ps
 1067  sudo docker ps -a
 1068  sudo docker rm  bc29dc52455a
 1069  sudo docker rm  09e79657d82c
 1070  sudo docker rm  93f712a5cd5a
 1071  sudo docker ps -a
 1072  sudo docker run -p -d --name webserver  8000:80 atbaker/nginx-example
 1073  sudo docker run -p --name webserver  8000:80 atbaker/nginx-example
 1074  sudo docker run -p   8000:80 --name webserver atbaker/nginx-example

 1064  sudo docker ps
 1065  sudo docker rm  a67fb408f218
 1066  sudo docker ps
 1067  sudo docker ps -a

=== stop/start/remove containers====
 1074  sudo docker run -d -p   8000:80 --name webserver atbaker/nginx-example

1043   sudo docker stop webserver
1043   sudo docker start webserver
1043   sudo docker rm webserver

 1003  sudo docker logs webserver
 1005  sudo docker diff  webserver
 1015  sudo docker inspect  webserver
 1016  sudo docker cp webserver:/usr/share/nginx/html/index.html .
 1020  sudo docker inspect 
 1021  sudo docker ps
 1022  sudo docker ps -aq

--- remove all containers ---
 1024  sudo docker rm -f $(sudo docker ps -aq)
 1025  sudo docker ps -aq
 1026  sudo docker ps -a

 sudo docker rmi -f $(sudo docker images -aq)
sudo docker rm $(sudo docker ps -a |grep mapserver | awk '{ print $1 }')

--- build from docker file ---
 sudo docker build -t nginx-static .
 sudo docker run  -p 8080:80 nginx-static
 (expose 80--on container, 8080 on host)
 sudo docker ps
 sudo docker inspect fe9ee3f0e4d
 (note network settings)
 <code>
 "NetworkSettings": {
        "Bridge": "docker0",
        "Gateway": "172.17.42.1",
        "IPAddress": "172.17.0.32",
        "IPPrefixLen": 16,
        "MacAddress": "02:42:ac:11:00:20",
        "PortMapping": null,
        "Ports": {
            "443/tcp": null,
            "80/tcp": [
                {
                    "HostIp": "0.0.0.0",
                    "HostPort": "8080"
                }
            ]
        }
    },

  access from http://172.17.42.1:8080/ or http://localhost:8080/
</code>

=== geonet ===
https://github.com/GeoNet/geonet/blob/master/README-DB.md

-- remove image
sudo docker rmi  3e643e0df8dc

-- docker build specify directory for docker file
sudo docker build -t 'geonet/postgis' ./db/
sudo docker run --name geonet_postgis -p 5432:5432 -i -d -t geonet/geonet

------ geonet-news-md
sudo docker build  -t 'geonet-news-md' .
sudo docker run --name geonet-news-md -p 8080:8080 -i -d -t geonet-news-md
sudo docker stop/start geonet-news-md

sudo docker run --name geonet-fits-web -p 8080:8080 -i -d -t geonet-fits-web

-- find ip address of a running container:
docker inspect --format '{{ .NetworkSettings.IPAddress }}' geonet_fit

sudo docker run -e "FITS_DATABASE_HOST=172.17.0.2"  -e "FITS_DATABASE_PASSWORD=test" -e "FITS_DATABASE_SSL_MODE=disable" -e "FITS_DATABASE_MAX_OPEN_CONNS=30" -e "FITS_DATABASE_MAX_IDLE_CONNS=20" -e "FITS_WEB_SERVER_PORT=8080" -e "FITS_WEB_SERVER_CNAME=localhost" -e "FITS_WEB_SERVER_PRODUCTION=false" -e "LIBRATO_USER=" -e "LIBRATO_KEY=" -e "LOGENTRIES_TOKEN="  -p 8080:8080 geonet-fits-web

psql --host=127.0.0.1  --username=hazard_w hazard -f events.ddl

------
hazdb docker

 cd dev/go/src/github.com/GeoNet/haz/etc/
# 1. build image
  518  sudo docker build -t 'hazdb' ./
  519  sudo docker images
  521  sudo docker ps -a
# 2. run container  
  523  sudo docker run --name hazdb -p 5432:5432 -i -d -t hazdb
  524  sudo docker ps -a
# 3. init db
  527  ll scripts/
  528  ./scripts/initdb.sh 

# 4. load quakes into db
cd cmd/haz-db-loader 
# vim env.list # edit SC3_SPOOL_DIR=/Users/baishan/work/seismcompml07  
envlist
export SC3_SPOOL_DIR=/Users/baishan/work/seismcompml07 
./haz-db-loader 

======
2016-03-11
update docker
https://docs.docker.com/linux/step_one/

sudo yum remove libdb4-4.8.30-11.fc20.x86_64
sudo yum remove libertas-usb8388-firmware-20150521-48.git3161bfa4.fc20.noarch
sudo yum remove libgssglue-0.4-2.fc19.x86_64
sudo yum remove liblognorm-0.3.7-1.fc20.x86_64
sudo yum remove libmicrohttpd-0.9.34-2.fc20.x86_64
sudo yum remove libopenraw-gnome-0.0.9-6.fc20.x86_64
sudo yum remove libproxy-mozjs-0.4.11-8.fc20.x86_64
sudo yum remove libreoffice-4.2.8.2-8.fc20.x86_64
sudo yum remove libreoffice-langpack-en-4.2.8.2-8.fc20.x86_64
sudo yum remove libreport-newt-2.2.3-3.fc20.x86_64
sudo yum remove libsane-hpaio-3.14.10-3.fc20.x86_64
sudo yum remove libytnef-1.5-11.fc20.x86_64
sudo yum remove libzeitgeist-0.3.18-5.fc20.x86_64
sudo yum remove pulseaudio-libs-glib2-5.0-25.fc20.i686
bpeng commented 8 years ago
grpc aws eb deploy
  1. running existing built exec not successful, possibly due to go version issue
  2. build from src in container
eb ssh

sudo docker ps -a
    4  sudo docker run -it 5a8625fb6321 /bin/bash
    5  sudo docker run -it 2bfb46e987f3 /bin/bash

root@fd110e61cafe:/go/src/github.com/gclitheroe/grpc-exp/mtr-api# history 

    2  ls -l
    3  cd mtr-api/
    7  export $(cat env.list | grep = | xargs)
    8  env
    9  go build
   36  mkdir github.com/gclitheroe/grpc-exp
   37  mkdir -p github.com/gclitheroe/grpc-exp
   38  cp -r app/* github.com/gclitheroe/grpc-exp/
   39  cd github.com/gclitheroe/grpc-exp  
   43  go build

 error: 
 golang.org/x/net/http2
/go/src/golang.org/x/net/http2/transport.go:219: req.Cancel undefined (type *http.Request has no field or method Cancel)

need go1.5 above  

3 desirable to push docker image to hub and deploy from there to eliminate the go version issue

bpeng commented 8 years ago

https://github.com/GeoNet/DevTools/blob/master/deploy/AWS-ECS.md https://github.com/GeoNet/DevTools/blob/master/deploy/ecr-prod.sh

moving our Docker images from quay.io to AWS ECR in Sydney.

AWS resources can use the "AmazonEC2ContainerRegistryReadOnly" policy so there is no need for them to have authentication credentials.

If you have auth tokens for the AWS prod account already then to get a 12 hour Docker login

eval $(aws --profile=production ecr get-login --region ap-southeast-2)

then for example docker pull 862640294325.dkr.ecr.ap-southeast-2.amazonaws.com/haz-db-consumer:latest

You need to install the AWS CLI and set up config using the tokens I send. I suggest a "production" profile but up to you http://docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-started.html

bpeng commented 7 years ago

geoserver-docker

https://github.com/GeoNode/geoserver-docker

docker pull geonode/geoserver
docker run --name "geoserver" -d -p 8082:8080 geonode/geoserver

Result:

bpeng commented 7 years ago

http://localhost:8182/cgi-bin/mapserv?map=/map/wms.map&mode=browse&template=openlayers&layers=landcover

http://localhost:8182/cgi-bin/mapserv?map=/map/wms.map&layers=landcover&mode=map&map_imagetype=png&mapext=172.02544325+-42.21037575+177.03523525+-37.20058375&imgext=172.02544325+-42.21037575+177.03523525+-37.20058375&map_size=512+512&imgx=256&imgy=256&imgxy=512+512


- Use in leaflet

http://mac16540.gns.cri.nz:8000/leaflet-base-layers.html

 //landCoverWms proxied on local mapserver using wms_client
    var mapServerWmsUrl = '//' + jQuery(location).attr('hostname') + ':8182/cgi-bin/mapserv?map=/map/wms.map';

    var landCoverWmsMapserver = L.tileLayer.wms(mapServerWmsUrl, {
        layers: 'landcover',
        format: 'image/png',
        transparent: true,
        srs: 'EPSG:900913'

    });

- wms.map

MAP CONFIG "MS_ERRORFILE" "/tmp/generic_map_error.txt" DEBUG 5 NAME "WMS_CLIENT" SIZE 512 512 UNITS meters SHAPEPATH "/map/"

SYMBOLSET symbolset.txt

EXTENT 160 -47.0 180.0 -32.0 ##EXTENT [minx] [miny] [maxx] [maxy]
PROJECTION
    'init=epsg:3857'
END #PROJECTION

IMAGECOLOR -1 -1 -1
IMAGEQUALITY 80
IMAGETYPE PNG

WEB
    IMAGEPATH '/tmp/'
    IMAGEURL '/tmp/'

    METADATA
      'ows_title'           'Generic Map'
      'ows_srs'             'EPSG:3857 EPSG:4326 EPSG:900913'      
      'wms_feature_info_mime_type' "text/html" 
      'ows_enable_request'   '*'
    END 
END     

###wms client
LAYER
   NAME "country_bounds"
   TYPE RASTER
   STATUS ON
   CONNECTION "http://demo.mapserver.org/cgi-bin/wms?"
   CONNECTIONTYPE WMS
   METADATA
     "wms_srs"             "EPSG:4326"
     "wms_name"            "country_bounds"
     "wms_server_version"  "1.1.1"
     "wms_format"          "image/gif"
   END
END   

LAYER
   NAME "landcover"
   TYPE RASTER
   STATUS ON
   CONNECTION "http://maps.scinfo.org.nz/basemaps/wms?"
   CONNECTIONTYPE WMS
   METADATA
       "wms_srs"             "EPSG:2193"
       "wms_name"            "landscape_eco_painted_relief"
       "wms_server_version"  "1.1.1"
       "wms_format"          "image/png"
   END
END

END