Learn how to use docker.io containers to consistently deploy your apps on any infrastructure.
- Read the official "What is Docker?" post: https://www.docker.com/whatisdocker
- Watch the intro vide: https://www.youtube.com/watch?v=ZzQfxoMFH0U
- Try the online demo: https://www.docker.com/tryit/
If your laptop/pc is not running Linux you will need to Download the Docker Toolkit**.pkg** (Mac) or docker-toolkit.exe (Windows) and install it on your Mac/PC.
- Mac: http://docs.docker.com/installation/mac/
- Windows: http://docs.docker.com/installation/windows/
- Linux: you already have LXC but can install a native docker package by clicking "Linux" and selecting your distro from the list or installing a binary: http://docs.docker.com/installation/binaries/
Sadly, Docker Toolkit is the "official" way of running docker on Mac
so we have to swallow the 453Mb pill
and get on with it! (click install!)
### Next Steps
You might as well get a Docker Hub account now (reserve your username on dockerhub): https://hub.docker.com/ Docker Hub lets you store your docker files (public & private) so you can share these with people and deploy them anywhere.
Open the Docker Quickstart Terminal App
This will open your terminal and run the boot script (wait a couple of minutes for it to finish...)
Run the suggested command:
$ docker run hello-world
Next try to run an ubuntu container (only do this on a fast internet connection as its going to download 65mb ubuntu image)
docker run -it ubuntu bash
This will boot the Ubuntu image and log you into the container's bash.
You can confirm that you are in a Linux bash by running the following
command: cat /etc/os-release
List the containers currently running:
docker-machine ls
Which shows:
NAME ACTIVE DRIVER STATE URL SWARM
default virtualbox Running tcp://192.168.99.100:2376
And for even more detail, run docker info
Containers: 2
Images: 6
Storage Driver: aufs
Root Dir: /mnt/sda1/var/lib/docker/aufs
Backing Filesystem: extfs
Dirs: 10
Dirperm1 Supported: true
Execution Driver: native-0.2
Logging Driver: json-file
Kernel Version: 4.0.9-boot2docker
Operating System: Boot2Docker 1.8.1 (TCL 6.3); master : 7f12e95 - Thu Aug 13 03:24:56 UTC 2015
CPUs: 1
Total Memory: 1.956 GiB
Name: default
ID: VIPW:LYBS:LT7I:KWTS:DU5U:W2NG:MWMH:EQNS:PFTF:4ZLN:STYL:4HG2
Debug mode (server): true
File Descriptors: 9
Goroutines: 20
System Time: 2015-08-16T22:27:21.593654583Z
EventsListeners: 0
Init SHA1:
Init Path: /usr/local/bin/docker
Docker Root Dir: /mnt/sda1/var/lib/docker
Labels:
provider=virtualbox
First build the image:
docker build -t learn-docker .
Then run the image as a container:
docker run -it -p 8888:8888 learn-docker bash
Exec
docker exec -it learn-docker bash
View the current (locally) available docker images:
$ docker images
You should see:
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
learn-docker latest 0c495aa0e6dc Less than a second ago 261.6 MB
ubuntu 14.04 8251da35e7a7 8 days ago 188.4 MB
ubuntu latest 8251da35e7a7 8 days ago 188.4 MB
hello-world latest af340544ed62 9 days ago 960 B
To list all the running docker containers, use:
docker ps -a
To get more detail on a container type: docker inspect {imageid}
e.g: in our case the container we are interested in has the id: a205fc3a096f so we run:
docker inspect a205fc3a096f
The complete output of this command is in: /sample-docker-inspect.txt
If all we want is the container's IP address we run:
docker inspect --format '{{ .NetworkSettings.IPAddress }}' a205fc3a096f
where the last argument is the container (image) id.
Courtesy of: http://stackoverflow.com/a/20686101/1148249
docker stop a205fc3a096f
For some reason I'm unable to access the nginx server running inside the docker container ... looked at:
- http://stackoverflow.com/questions/31324981/how-to-access-host-port-from-docker-container
- http://stackoverflow.com/questions/31448249/how-to-deploy-web-service-on-docker-container
- http://stackoverflow.com/questions/27714900/nginx-on-docker-daemonize-and-attach-to-bash
Test that your nginx configuration is valid (doen't have errors)
sudo nginx -t
expect the following output:
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
- Command Line Reference: http://docs.docker.com/reference/commandline/cli
- Cheat Sheet: https://github.com/wsargent/docker-cheat-sheet
- Build Podcast Docker: http://build-podcast.com/docker/
- Introduction to Docker - (Twitter University): https://www.youtube.com/watch?v=Q5POuMHxW-0 47mins - 2mins of content!
- Be a happier developer with Docker: https://www.youtube.com/watch?v=XCVOxht34Hs 25mins - relevant to developers