What is Docker?

Installation of docker

$ brew cask list
$ brew cask install docker
$ brew cask install docker-toolbox

Some docker commands

search images
$ docker search elasticsearch
list images
$ docker images
list containers
$ docker ps
$ docker ps -a | grep 60afe4036d97
list all running containers
$ docker ps -a -f status=running
remove container
$ docker rm <containerid>
remove multiple container
$ docker rm 305297d7a235 ff0a5c3750b9
$ docker rm $(docker ps -a -q -f status=exited)
remove image
$ docker rmi <imageid>
remove all images
$ docker rmi $(docker images -q)
start container
$ docker start zen_leavitt
$ docker start -ai zen_leavitt
stop container
$ docker stop zen_leavitt

create machine
$ docker-machine create --driver virtualbox default

rename container
$ docker rename CONTAINER NEW_NAME
get container
$ docker pull glassfish
run container
$ docker run glassfish
get and run container
$ docker run -it glassfish bash
$ docker run -it glassfish sh

build container
docker build -t aripd/retweet .
run container
$ docker run -p 8888:5000 aripd/retweet
push container
$ docker push aripd/retweet
login to Docker Hub
$ docker login

$ docker run -d -p 8484:8080 --name horinca imworld/horinca
$ docker exec -it glassfish /bin/bash
$ mvn clean install && docker build -t imworld/horinca .
$ docker kill horinca

Updating and committing an image

$ docker run -t -i aripd/ecommerce /bin/bash
root@0b2616b0e5a8:/# asadmin change-admin-password
root@0b2616b0e5a8:/# asadmin enable-secure-admin
... etc.
$ docker commit -m "Made some changes" -a "aripddev" 0b2616b0e5a8 aripd/ecommerce:v2
$ docker images
$ docker run -t -i aripd/ecommerce:v2 /bin/bash
$ docker history aripd/ecommerce:v2

commit and push docker images to dockerhub

docker ps
docker commit c3f279d17e0a  aripd/testimage:version3
docker images
docker login
docker push aripd/testimage

isolated network

Dockerfile

FROM        glassfish:latest
MAINTAINER  aripddev <dev@aripd.com>
RUN         apt-get update
RUN         curl http://repo1.maven.org/maven2/mysql/mysql-connector-java/5.1.40/mysql-connector-java-5.1.40.jar -o glassfish/lib/mysql-connector-java-5.1.40.jar
COPY        domain.xml glassfish/domains/domain1/config/domain.xml
COPY        admin-keyfile glassfish/domains/domain1/config/admin-keyfile
COPY        target/ecommerce-3.0-SNAPSHOT.war glassfish/domains/domain1/autodeploy/ecommerce-3.0-SNAPSHOT.war
EXPOSE      8080 4848 8181

jdbc url is jdbc:mysql://mydatabase:3306/Database_Name

$ docker network create my-network
$ docker run -d --net=my-network --name=mydatabase -e MYSQL_ROOT_PASSWORD='Q1w2e3r+' mysql
$ unset GEM_PATH
$ mvn clean install && docker build -t aripd/ecommerce .
$ docker run -d --net=my-network --name=myapp aripd/ecommerce