docker-engine not docker.io anymore
docker.io is old name
# Debian Jessie 8.0 (64-bit) or unstable packages
$ sudo apt-get update
$ sudo apt-get install docker-engine
# if virtualbox not installed, install via homebrew cask
http://docs.docker.com/installation/mac/#from-your-shell
$ brew install caskroom/cask/brew-cask
$ brew cask install dockertoolbox
# start docker engine
$ docker-machine create
$ eval "$(docker-machine env default)"
#debian
$ sudo groupadd docker
$ sudo gpasswd -a ${USER} docker # or sudo adduser ${USER} docker
$ sudo service docker restart
$ docker images --tree #list images in tree structure ('--tree' is deprecated)
$ docker ps -a #List all containers
$ docker ps -l #List lastest containers
$ docker ps -q #List containers display on IDs (quiet)
$ docker run -i -t <image> /bin/bash
docker start `docker ps -q -l` # restart it in the background
docker attach `docker ps -q -l` # reattach the terminal & stdin
$ docker run --rm <imamge>
$ sudo docker ps -a | grep Exit | cut -d ' ' -f 1 | xargs sudo docker rm
# if space full in docker engine
$ docker rmi $(docker images | grep '<none>' | tr -s ' ' | cut -d ' ' -f 3)
# or
$ docker images -a | grep none | awk '{print $3}' | xargs docker rmi -f
# $ dokcer pull <images>
# Fix Repository debian already being pulled by another client. Waiting.
$ sudo service docker restart
# docker run option
# -v, --volume=[] create a volume
# -v host:container mount host directory to container
# ex. -v $PWD:/app , mount current path to /app in container
# -w, --workdir="" Working directory inside the container
$ docker run -v <host_dir_path>:<container_dir_path> -w <workdir_path> <image> <cmd>
#!/bin/bash
Q="0"
while [ $Q = "0" ]; do
Q=$(ping -c1 www.google.com 2> /dev/null | grep -c google);
done
echo Connected!
sudo service docker restart
$ docker exec <image> sh -c ‘<cmd>’
$ docker run <image> bash -c ‘<cmd>’
Dockerfile
# Docker env don't pass though cron jobs, you need to save env to file and load it in cron jobs.
# save Docker envoirment to file with command "env > <file>"
# To debug crontab see to run "rsyslogd" and see logs at "/var/log/syslo"
# CMD rsyslogd && && env > /root/env.sh && tail -f /var/log/cron.log
CMD cron && env > /root/env.sh && tail -f /var/log/cron.log
cron_task.sh
env - `cat /root/env.sh` $1
crontab
# always need ot >> to some where to avoid “(CRON) info (No MTA installed, discarding output)” error in the syslog
# http://askubuntu.com/questions/222512/cron-info-no-mta-installed-discarding-output-error-in-the-syslog
* * * * * root crontab_task.sh “<your command>" >> /var/log/cron.log 2>&1
#An empty line is required at the end of this file for a valid cron file.
$ docker-machine upgrade <machine>
$ echo "Asia/Bangkok" > /etc/timezone && dpkg-reconfigure -f noninteractive tzdata
$ docker login
# docker tag <image> <username/image:version>
$ docker tag viau10-app ibotdotout/viau10-app:latest
# docker push <username/image>
$ docker push ibotdotout/viau10-app
# private registry
$ docker tag <contrainer_id> <your_registry_domain>/<image>
$ docker push <your_registry_domain>/<image>
$ docker build --no-cache .
$ sudo rm -rf /var/lib/docker/aufs
$ docker ps -s
# you can use `docker-machine ssh < machine > instead this
# 192.168.99.100 this is ip for < machine >
# that can check via `docker-machine ip < machine >
$ ssh docker@192.168.99.100
# password: tcuser
# clean your mapping volume on host that was copied to docker machine
$ docker run --rm -v /var/run/docker.sock:/var/run/docker.sock:ro -v /var/lib/
``sh $ apt-get update && apt-get upgrade -y $ apt-get install -y python-pip $ pip install -U docker-compose
### Docker-Compose Production
```sh
# https://docs.docker.com/compose/extends/
$ docker-compose -f production.yml
$ apt-get install -y --no-install-recommends <packages>