Skip to content

Instantly share code, notes, and snippets.

@luebken
Created June 2, 2015 09:28
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save luebken/327eac541f939e2202a2 to your computer and use it in GitHub Desktop.
Save luebken/327eac541f939e2202a2 to your computer and use it in GitHub Desktop.
Docker Intro Script

Prepartion:

docker pull docker pull giantswarm/helloworld
docker pull busybox:ubuntu-14.04
docker pull busybox
docker pull ghost
git clone https://github.com/giantswarm/giantswarm-firstapp-nodejs && make
git clone https://github.com/giantswarm/helloworld

Use Images:

docker images
docker images -tree
docker history giantswarm/helloworld
docker inspect <image id>

Images implementation:

boot2docker ssh
sudo -s
cd /var/lib/docker
find -name <imageid>

Container:

docker run busybox
docker run busybox echo hellworld
docker run -it busybox
docker run -d busybox /bin/sh -c "while true; do echo hello; sleep 1; done"
docker pull ghost && docker run --name some-ghost -d ghost

Expose and publish ports:

docker run -it --name webserver --expose 80 busybox
echo hello > nc-response
while true; do nc -l -p 80 < nc-response; done

docker run -it --link webserver:webserver node /bin/sh
curl webserver
env
curl <ip>:<port>

Create images by hand:

docker inspect <imageid>
docker diff <imageid>

# commit the file nc-response
docker commit webserver
docker history <image id>

#commit the command
docker run -P <73031261815e> /bin/sh -c "while true; do nc -l -p 80 < nc-response; done"
docker commit <containerid>

Create images with a Dockerfile

cd giantswarm-firstapp-nodejs
cat Dockerfile

Volumes

cd /Users/mdl/workspace/giantswarm/helloworld
docker run -v `pwd`:`pwd` -w `pwd` -it busybox:ubuntu-14.04 ./helloworld

Useful commands:

docker rm $(docker ps -aq)
docker rmi $(docker images -q --filter dangling=true)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment