Docker

#see http://stackoverflow.com/questions/19585028/i-lose-my-data-when-the-container-exits
#see https://coderwall.com/p/2es5jw/docker-cheat-sheet-with-examples
#When you use docker run to start a container, it actually creates a new container 
#based on the image you have specified.
#you can restart an existing container after it exited and your changes are still there.
docker start f357e2faab77 # restart it in the background
docker attach f357e2faab77 # reattach the terminal & stdin

#Preparing a private registry
#see https://docs.jelastic.com/docker-private-registry
#see http://stackoverflow.com/questions/33392972/how-can-i-update-docker-opts-in-docker-machine-permanently
#For windows docker 1.13
#initiate session
docker-machine ssh default
vi /var/lib/boot2docker/profile
#and put this params
EXTRA_ARGS='
--label provider=virtualbox
--insecure-registry=10.0.0.1:5000
'
#restart docker-machine restart default

#for dockerD in windows
#in windows dockerd resides inside the virtual machine, you have to enter in session. Version 1 of docker-toolbox.
#if you want to tweak some configuration, you have to create the file: 
sudo touch /etc/docker/daemon.json
#locate the pid of the dockerd daemon process
ps -uxa|grep dockerd
#kill by reloading its new config
kill -SIGHUP pidOfDockerd
#more options in
#see https://github.com/docker/docker/blob/master/docs/reference/commandline/dockerd.md

Advertisements

Notes of Docker

VirtualBox-5.1.14-112924-Win.exe -msiparams NETWORKTYPE=NDIS5
docker-machine create --virtualbox-disk-size 40000 -d virtualbox mplescano

docker-machine create --vmwareworkstation-disk-size 40000 -d vmwareworkstation mplescano

docker run -it --name iif_innovator_c --privileged -p 9088:9088 -p 9089:9089 -p 27017:27017 -p 27018:27018 -p 27883:27883 -e LICENSE=accept ibmcom/informix-innovator-c:latest

#see https://github.com/docker/kitematic/wiki/Common-Proxy-Issues-&-Fixes
#see http://www.netinstructions.com/how-to-install-docker-on-windows-behind-a-proxy/ (incomplete)
#Here I prefer to put ENV http_proxy=http://example.com:8080 in the docker file
docker-machine create -d virtualbox \
    --engine-env HTTP_PROXY=http://example.com:8080 \
    --engine-env HTTPS_PROXY=https://example.com:8080 \
    --engine-env NO_PROXY=example2.com \
    default
	
	
#use SCP to copy certificates
#see https://github.com/docker/machine/issues/1799
#see https://github.com/boot2docker/boot2docker#installing-secure-registry-certificates
#see https://support.ssl.com/Knowledgebase/Article/View/19/0/der-vs-crt-vs-cer-vs-pem-certificates-and-how-to-convert-them
#see docker-machine scp --help
$ docker-machine scp localhost:/D/Users/njoaquin.programador/Downloads/SUNATCA_autosigned.X_509.base64.cer mplescano:sunatca.crt
$ docker-machine ssh mplescano
$ sudo mkdir /var/lib/boot2docker/certs
$ sudo mv sunatca.crt /var/lib/boot2docker/certs/
$ docker-machine restart mplescano

#################################################
#in order to push images, it's necessary to copy the CA cert in others folders..
#Log docker: /var/log/docker.log
#hostDir: /etc/docker/certs.d/index.docker.io, /etc/docker/certs.d/docker.io
#for root see http://stackoverflow.com/questions/32646952/docker-machine-boot2docker-root-password
sudo -i
mkdir /etc/docker/certs.d
mkdir /etc/docker/certs.d/index.docker.io
mkdir /etc/docker/certs.d/docker.io
mkdir /etc/docker/certs.d/registry-1.docker.io
sudo ln -s /var/lib/boot2docker/certs/sunatca.crt /etc/docker/certs.d/index.docker.io/sunatca.crt
sudo ln -s /var/lib/boot2docker/certs/sunatca.crt /etc/docker/certs.d/docker.io/sunatca.crt
sudo ln -s /var/lib/boot2docker/certs/sunatca.crt /etc/docker/certs.d/registry-1.docker.io/sunatca.crt



#this doesnt work and doesnt persist if it's restarted the docker-machine
#cat /usr/local/etc/ca-certificates.conf
#/usr/local/share/ca-certificates/mozilla/, /usr/local/share/ca-certificates/extra/
sudo mkdir /usr/local/share/ca-certificates/extra/
sudo cp /var/lib/boot2docker/certs/sunatca.crt /usr/local/share/ca-certificates/extra/
sudo ln -s /var/lib/boot2docker/certs/sunatca.crt /usr/local/share/ca-certificates/extra/sunatca.crt
sudo echo "extra/sunatca.crt" >> /usr/local/etc/ca-certificates.conf

#start a session login
docker -D -l debug --tlsverify=false login --username=mplescano
########################################################

#use bash of git in windows
#Delete all container in exited status
docker rm $(docker ps -a|grep ".*Exited.*"|awk "{print \$1}")
#Delete all container in created status
docker rm $(docker ps -a|grep ".*Created.*"|awk "{print \$1}")
#delete images
docker rmi $(docker images | grep "^" | awk "{print \$3}")


########################################################