Giter Club home page Giter Club logo

learn-docker's Introduction

Docker: Believe the Hype!

Docker Logo

Learn how to use docker.io containers to consistently deploy your apps on any infrastructure.

What? (Quick Introduction)

Try

Installation

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.

docker-toolbox-453-mb

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!)

docker-toolkit-installation-summary

### 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

Open the Docker Quickstart Terminal App

use-spotlight-to-open-quickstart-app

This will open your terminal and run the boot script (wait a couple of minutes for it to finish...) quickstart

Run the suggested command:

$ docker run hello-world

docker-configured

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

download ubuntu

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

confirm-running-ubuntu

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

Run the Dockerfile in this repo

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

https://docs.docker.com/reference/run/

Exec

docker exec -it learn-docker bash

List (Locally Available) Images

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

docker ps

To list all the running docker containers, use:

docker ps -a

https://docs.docker.com/reference/commandline/ps/

More info on a specific container

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

Just the IP address

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

Kill a Container by ID

docker stop a205fc3a096f

https://docs.docker.com/reference/commandline/stop/

Help!

For some reason I'm unable to access the nginx server running inside the docker container ... looked at:

is nginx working?

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

Useful Links

Cheat Sheet

Videos

Tutorials

learn-docker's People

Contributors

iteles avatar nelsonic avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.