Docker Keynotes
Deployment Architecture:
Docker container can be deployed on:
1. Container orchestration tool like Kubernetes, Docker Swarm, OpenShift, etc for production purpose
2. Docker Daemon for development purpose
Container Isolation Architecture
OS internal used for environment isolation:
Resources managed by OS facilities
Namespaces:
- Process
- Network
- IPC
- Mount
- User
CGroups:
- Resource limits
Security:
- SELinux
Container — Host communication Architecture
Terminology
Layer: a set of read-only files to provision the system
Container: Running instance containing required s/w Created from images
Image: a read-only layer that is the base of your container. Might have a parent image
Port: Can be visible and invisible to outer world
Volume: Shared folder
Registry / Hub: central place where images live
Docker hub: Registry with web UI
Docker machine: a VM to run Docker containers (Linux does this natively)
Docker compose: a utility to run multiple containers as a system
Commands:
docker run ubuntu /bin/echo ‘Hello world’
Docker cleanup commands
- Kill all running containers: docker kill $(docker ps -q)
2. Delete dangling images: docker rmi $(docker images -q -f dangling=true)
3. Remove all stopped containers: docker rm $(docker ps -a -q)
4. Create and start containers: docker-compose up
Interacting with a container
- Run a command in the container: docker exec -ti container_name command.sh
2. Follow the container logs: docker logs -ft container_name
3. Save a running container as an image: docker commit -m “commit message” -a “author” container_name username/image_name:tag
Docker machine commands
Use docker-machine to run the containers
- Start a machine: docker-machine start machine_name
2. Configure docker to use a specific machine: eval “$(docker-machine env machine_name)”
Useful one-liners
- Download an image: docker pull image_name
2. Start and stop the container: docker [start|stop] container_name
3. Create and start container, run command: docker run -ti — name container_name image_name command
4. Create and start container, run command, destroy container: docker run — rm -ti image_name command
Example filesystem and port mappings
docker run -it — rm -p 8080:8080 -v /path/to/agent.jar:/agent.jar -e JAVA_OPTS=”-javaagent:/agent.jar” tomcat:8.0.29-jre8