Download presentation
Presentation is loading. Please wait.
Published byMarjorie Cole Modified over 10 years ago
1
Kat Passen
2
Open source platform to manage deployment Acts as a layer between an OS and an application Images not dependent on system – similar to the JVM Provides a “global standard” to code against
3
VMs require apps to be containered within the guest OS Potentially 1:1 on VM:application Docker sits between the app and the host OS Takes place of the hypervisor Runs images as an isolated process Only the app and its libraries are compartmentalized instead of requiring the guest OS share that space as well
4
Installation: Available on a variety of platforms: ▪ Your favorite *nix ▪ Windows ▪ Rackspace, EC2, G-Cloud, etc
5
Requirements: iptables git procps or similar XZ Utils A cfgroups hierarchy Kernel requirements vary by distribution, general recommendation is v3.8+
6
Important: Docker runs as root Giving non-root access The docker daemon always runs as the root user, and the docker daemon binds to a Unix socket instead of a TCP port. By default that Unix socket is owned by the user root, and so, by default, you can access it with sudo. If you (or your Docker installer) create a Unix group called docker and add users to it, then the docker daemon will make the ownership of the Unix socket read/writable by the docker group when the daemon starts. The docker daemon must always run as the root user, but if you run the docker client as a user in the docker group then you don't need to add sudo to all the client commands.
7
Docker Engine Client-server application Handles running images, registries and containers Docker Hub Public Docker registry Holds a collection of existing images to be used publicly Image examples: Ubuntu, Node.js, MongoDB, WordPress
8
Integrates with Github and Bitbucket Operates similar to them as well Hosts images that can be used and contributed to by the Docker community Location that Docker pulls and pushes to
9
Tutorial: https://www.docker.com/tryit/https://www.docker.com/tryit/ Operates similar to any other *nix command line application
10
Interactive containers: $ sudo docker run -t -i ubuntu:14.04 /bin/bash ▪ -t creates a pseudo-terminal ▪ -i captures STDIN Results (example): root@af8bae53bdd3:/# pwd / root@af8bae53bdd3:/# ls bin boot dev etc home lib lib64 media mnt opt proc root run sbin srv sys tmp usr var
11
Hello world daemon $ sudo docker run -d ubuntu:14.04 /bin/sh -c "while true; do echo hello world; sleep 1; done“ ▪ -d runs containers in the background (daemonizes them) This example returns a container ID, which you can use to interact with the container running that command To stop a container, use docker stop $container_name
12
Docker’s example runs a Python Flask app: $ sudo docker run -d -P training/webapp python app.py ▪ -P: map required network ports inside the container to the host Check results with sudo docker ps –l : ▪ CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES bc533791f3f5 training/webapp:latest python app.py 5 seconds ago Up 2 seconds 0.0.0.0:49155->5000/tcp nostalgic_morse ▪ -l: tells docker ps to return the last container started
13
Ports: super malleable -P is a shortcut for –p 5000 Docker generally picks a high external port to map to Can run 1:1 on your port mappings, but this way you can have multiple apps thinking they’re on the same port Lookup: use docker port $container_name $port
14
View logs: docker log $container_name Add -f and it behaves the same as tail –f Other neat things: docker top – same as standard top docker inspect – returns a JSON hash of config and status info docker tag – set a tag on an image (e.g. ‘devel’)
15
Start/stop/restart docker start $container_name docker stop $container_name docker restart $container_name Removing things Containers: ▪ docker rm $container_name ▪ Container in question has to be stopped first Images: ▪ docker rmi $image_name All deletions are final
16
Updating and committing to an existing image: Create a container from the image you want to update Add what you want to the container, exit Commit changes: ▪ $ sudo docker commit -m="Added json gem" -a="Kate Smith" 0b2616b0e5a8 ouruser/sinatra:v2 ▪ Params after flags: source container ID and user/target_name:tag
17
Build an image from a Dockerfile Dockerfile: set of instructions telling Docker how to create an image Takes the format of INSTRUCTION statement ▪ # This is a comment FROM ubuntu:14.04 MAINTAINER Kate Smith RUN apt-get update && apt-get install -y ruby ruby-dev RUN gem install sinatra
18
Build an image from a Dockerfile (cont) In the same directory, run docker build – t=“$image_name” $path ▪ $ sudo docker build - t="ouruser/sinatra:v2". Now you can create a container from the new image! Size caveat: images have a maximum of 127 layers
19
http://docs.docker.com/userguide/ http://docs.docker.com/userguide/
20
In no particular order: Dist::Zilla Rocket Bamboo Jenkins Chef Puppet Rex
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.