-
Notifications
You must be signed in to change notification settings - Fork 0
Home
GunSik2 edited this page Oct 30, 2015
·
3 revisions
Welcome to the docker wiki!
Virtualization
- Virtualization : Virtual Machine vs. Container
- VM: Hardware level, Type-1(bear metal) & Type 2(Virtual Box, VMWare,...) Hypervisor
- Container: OS level, namespace & cgroups(resource management) isolation, docker
Docker installation
- Windows & Linux : instal docker-toolbox
Docker container commands
- docker run busybox echo Hello Docker // create a container using busybox image
- docker ps -a
- docker rm
- docker inspect
Docker images commands
- run : create a container
- docker images
- docker rmi
- docker build
- docker commit
- docker save
- docker import
- docker history
- docker tag
Docker image creation & push to remote repository
- http://phusion.github.io/baseimage-docker/
- docker run -t -i phusion/baseimage:0.9.16 /sbin/my_init -- bash -l // extending base image
- docker ps -a
- docker commit phusion-base-with-vim // create a new image
- docker images
- docker tag cgshome2/phusion-base-with-vim:1.0.0
- docker login // use docker hub credential
- docker push cgshome2/phusion-base-with-vim:1.0.0 // push image to remote repository
Docker file
- cat Dockerfile // nodejs Source: package.json, index.js
# consists of base image, layer, command
FROM centos:centos6
RUN \
rpm -Uvh http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
RUN \
yum install -y npm
COPY . /src
RUN \
cd /src; npm install # install app dependency
EXPOSE 8080
CMD ["node", "/src/index.js"]
- docker build -t="cgshome2/hello-nodejs:1.0.0" . // docker build create images from Dockerfile
- Run daemonizely
- docker rm $(docker ps -qa)
- docker run -d -p 8080:8080 cgshome2/hello-nodejs:1.0.0 // run container
- docker ps -a
- docker logs -f
- docker inspect // to find ip
- curl -i :8080 // linux
- curl $(boot2docker ip):8080 // window & osx
- Run interactively
- docker run -d -p 8080:8080 -t -i --name dev cgshome2/javadev:1.0.0 bash // run container interactively
- docker attach dev // access into container
- curl -l localhost:8080
- cat Dockerfile // java
FROM java:openjdk-7-jdk
MAINTAINER GunSik
RUN \
apt-get update && \
echo "===> install maven" \
apt-get install -y maven
WORKDIR /code # Create a work directory
COPY pom.xml /code/pom.xml
COPY src /code/src
CMD ["mvn", "package"]
CMD ["mvn", "exec:java"]
EXPOSE 8080
Docker file for multiple node provisioning, orchestration, and automation
- Shutdown docker when app stops
- Chroot env.
- Namespaces : process isolation(ipc, uts, mount, pid, network, user)
- Control groups : resource isolation
- Container