# see the list of docker images as a tree view. Determine IMAGE_ID
sudo docker images --tree
# get list of currently running containers. Determine CONTAINER_ID
sudo docker ps
# remove a docker image tree
sudo docker rmi IMAGE_ID/TAG
# get list of all containers
sudo docker ps -a
# get last executed container info
sudo docker ps -al
# get all containers without the command being truncated
sudo docker ps -a --no-trunc
# commit changes to a docker container and tag the commit
sudo docker commit CONTAINER_ID feature/nginx
# tag an image without running
sudo docker tag IMAGE_ID TAG_NAME
# run a tag or IMAGE_ID as an interactive bash shell
sudo docker run -t -i -p 80 feature/nginx /bin/bash
# remove the container after running
sudo docker run -rm ….
# name a container
sudo docker run --name …
# run a tag or IMAGE_ID as an interactive ssh process
sudo docker run -t -i -p 22 -p 80 feature/nginx /usr/sbin/sshd -D
# run a tag or IMAGE_ID as a background ssh process
sudo docker run -d -p 22 -p 80 feature/nginx /usr/sbin/sshd -D
# view docker logs
sudo docker logs CONTAINER_ID/NAME
sudo docker logs -f CONTAINER_ID/NAME # follow
# stop a running container in the background or foreground
sudo docker stop CONTAINER_ID/NAME
# build and tag an image using a Dockerfile
docker build -t tag/name .
# run a docker process and open up ports 22 and 80 on the docker instance. The host ports are generated automatically.
sudo docker run -d -p 22 -p 80 feature/nginx /usr/bin/supervisord -n
# Get port on the host that is NATed to the given port on the image
sudo docker port CONTAINER_ID 22
sudo docker port CONTAINER_ID 80
# run a docker process and map host port 8888 to docker instance port 80 and host port 2222 to docker instance port 22
sudo docker run -d -p 2222:22 -p 8888:80 feature/nginx /usr/bin/supervisord -n
# Same as above but additionally creates a shared folder between the host and guest
sudo docker run -d -p 2222:22 -p 8888:80 -v /home/:/home/:rw feature/nginx /usr/bin/supervisord -n
# clean up extra containers
sudo docker rm `sudo docker ps -a | grep Exit | awk '{ print $1}'`
sudo docker rm $(sudo docker ps -a -q)
# NEW: clean up exited containers
sudo docker ps -a -q --filter status=exited | xargs docker rm
# NEW: clean up untagged images
docker images -q --filter "dangling=true" | xargs docker rmi
# delete all untagged images
sudo docker rmi $( sudo docker images | grep '' | tr -s ' ' | cut -d ' ' -f 3)
# In Ubuntu, change the docker daemon listen address for Shipyard
DOCKER_OPTS="-H tcp://127.0.0.1:4243 -H unix:///var/run/docker.sock"
service restart docker
# images files stored in
/var/lib/docker/graph/
# get the host gateway from within the container
netstat -nr | grep '^0\.0\.0\.0' | awk '{print $2}'
# find metatdata bout the container
sudo docker inspect CONTAINER_ID/NAME
# Setup shipyard-agent
curl https://github.com/shipyard/shipyard-agent/releases/download//shipyard-agent -L -o /usr/local/bin/shipyard-agent
chmod +x /usr/local/bin/shipyard-agent
shipyard-agent -url http://myshipyardhost:shipyardport -register # register with shipyard
shipyard-agent -url http://myshipyardhost:shipyardport -key 1234567890qwertyuiop # run the agent
SETUP AN IMAGE
sudo aptitude install nginx vim openssh-server supervisord psmisc
vim /etc/supervisor/conf.d/nginx.conf
[program:nginx]
command=/usr/sbin/nginx -c /etc/nginx/nginx.conf
directory=/etc/nginx
user=root
autostart=true
autorestart=true
redirect_stderr=True
vim /etc/supervisor/conf.d/ssh.conf
[program:sshd]
command=/usr/sbin/sshd -D
FLATTEN IMAGE
http://www.hnwatcher.com/r/650964/Slimming-down-Docker-containers-Intercity-Blog
CONTAINER_ID=$(docker run -d image-name /bin/bash)
docker export $CONTAINER_ID | docker import – flat-image-name
CONTAINER_ID=$(docker run -d image-name /bin/bash)
(docker export $CONTAINER_ID | gzip -c > image.tgz)
gzip -dc image.tgz | docker import - flat-image-name
OTHER
lxc-attach
--links option
--env-file
https://gist.github.com/wsargent/7049221#images
Remove images article
http://mikehadlow.blogspot.com/2014/04/docker-bulk-remove-images-and-containers.html
Linking Containers
http://docs.docker.com/userguide/dockerlinks/
Dockerfile Reference
http://docs.docker.com/reference/builder/
FLYNN - Open Source PaaS
https://github.com/flynn/flynn
ETCD - Configuration Tool
https://github.com/coreos/etcd
1 comment:
god status!
Post a Comment