SlideShare a Scribd company logo
Docker: Tips & Tricks
Dharmit Shah
@dharm1t
Who am I?
(Earlier)
@
@
Nice `docker ps` output
$ docker ps -a | less -S
Follow the logs
$ docker logs <containerid> -f
Stats for running container
$ docker stats <container-id> <container-id> … <container-id>
Copy files from host to container
$ docker cp /file/on/host <container-id>:/path/in/container
Fetch single value from docker
inspect
$ docker inspect --format '{{.State.Running}}' $(docker ps -lq)
$ docker inspect --format '{{.NetworkSettings.IPAddress}}' $(docker ps -lq)
docker exec instead of sshd or
nsenter
$ docker exec -it <container-id> /bin/bash
Old man staring at your mouse!
$ xhost local:root
$ docker run -d 
-e DISPLAY=$DISPLAY 
-v tmp/.X11-unix:/tmp/.X11-unix xeji
Docker  tips & tricks
FROM debian:squeeze
RUN apt-get update && 
apt-get install -y xeji
RUN export uid=1000 gid=1000 && 
mkdir -p /home/developer && 
echo "developer:x:${uid}:${gid}:Developer,,,:/home/developer:/bin/bash" >>
/etc/passwd && 
echo "developer:x:${uid}:" >> /etc/group && 
echo "developer ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/developer && 
chmod 0440 /etc/sudoers.d/developer && 
chown ${uid}:${gid} -R /home/developer
USER developer
ENV HOME /home/developer
ENTRYPOINT ["/usr/bin/xeji"]

More Related Content

PDF
Docker導入手順
PDF
Configuration surgery with Augeas (OggCamp 12)
PDF
PDF
37562259 top-consuming-process
PDF
Docker & CoreOS at Utah Gophers
PPTX
Awk primer and Bioawk
DOCX
serverstats
PDF
KubeCon EU 2016: Custom Volume Plugins
Docker導入手順
Configuration surgery with Augeas (OggCamp 12)
37562259 top-consuming-process
Docker & CoreOS at Utah Gophers
Awk primer and Bioawk
serverstats
KubeCon EU 2016: Custom Volume Plugins

What's hot (19)

PDF
Bash Scripting Workshop
PDF
Go初心者がGoでコマンドラインツールの作成に挑戦した話
KEY
Clojure + MongoDB on Heroku
PPTX
Ansible for Beginners
PDF
Intro to Systems Orchestration with MCollective
PPTX
(Practical) linux 101
PPTX
(Practical) linux 104
PDF
HaskellとDebianの辛くて甘い関係
PDF
Dspace-1.8.2 Installation on Centos-6.3
PPTX
App-o-Lockalypse now!
PDF
Shell Script to Extract IP Address, MAC Address Information
PDF
Container Security
PPTX
Process monitoring in UNIX shell scripting
PDF
Redis as a message queue
PPTX
Comets notes
PPTX
Cis 216 – shell scripting
PPT
PDF
Performance Profiling in Rust
Bash Scripting Workshop
Go初心者がGoでコマンドラインツールの作成に挑戦した話
Clojure + MongoDB on Heroku
Ansible for Beginners
Intro to Systems Orchestration with MCollective
(Practical) linux 101
(Practical) linux 104
HaskellとDebianの辛くて甘い関係
Dspace-1.8.2 Installation on Centos-6.3
App-o-Lockalypse now!
Shell Script to Extract IP Address, MAC Address Information
Container Security
Process monitoring in UNIX shell scripting
Redis as a message queue
Comets notes
Cis 216 – shell scripting
Performance Profiling in Rust
Ad

Similar to Docker tips & tricks (20)

PPTX
Docker Introductory workshop
PDF
Docker in Action
PDF
Docker - from development to production (PHPNW 2017-09-05)
PPTX
Docker workshop DevOpsDays Amsterdam 2014
PDF
JDO 2019: Tips and Tricks from Docker Captain - Łukasz Lach
PDF
PuppetConf 2016: The Challenges with Container Configuration – David Lutterko...
PDF
Challenges of container configuration
DOCX
Really useful linux commands
PDF
Docker, the Future of DevOps
PPTX
Azure from scratch part 5 By Girish Kalamati
PPTX
Running Docker in Development & Production (DevSum 2015)
PDF
Docker & FieldAware
PDF
파이썬 개발환경 구성하기의 끝판왕 - Docker Compose
PPTX
Docker container management
PPTX
Docker workshop
PDF
Deploying Plone and Volto, the Hard Way
PDF
[EXTENDED] Ceph, Docker, Heroku Slugs, CoreOS and Deis Overview
PDF
PPTX
Docker practice
PDF
Using docker for data science - part 2
Docker Introductory workshop
Docker in Action
Docker - from development to production (PHPNW 2017-09-05)
Docker workshop DevOpsDays Amsterdam 2014
JDO 2019: Tips and Tricks from Docker Captain - Łukasz Lach
PuppetConf 2016: The Challenges with Container Configuration – David Lutterko...
Challenges of container configuration
Really useful linux commands
Docker, the Future of DevOps
Azure from scratch part 5 By Girish Kalamati
Running Docker in Development & Production (DevSum 2015)
Docker & FieldAware
파이썬 개발환경 구성하기의 끝판왕 - Docker Compose
Docker container management
Docker workshop
Deploying Plone and Volto, the Hard Way
[EXTENDED] Ceph, Docker, Heroku Slugs, CoreOS and Deis Overview
Docker practice
Using docker for data science - part 2
Ad

More from Dharmit Shah (13)

PDF
Introducing CentOS container pipeline
PDF
Introduction to Kubernetes
PDF
Introduction to Containers
PDF
Git push to build, test and scan your containers
PDF
Python in Industry
PDF
Swarm mode
PPTX
Ansible in CI
PPTX
Introduction to ansible
PDF
Kubernetes
PDF
Atomic Developer Bundle
PPTX
Introducing docker
PDF
Rest apis with DRF
PDF
Docker hands-on
Introducing CentOS container pipeline
Introduction to Kubernetes
Introduction to Containers
Git push to build, test and scan your containers
Python in Industry
Swarm mode
Ansible in CI
Introduction to ansible
Kubernetes
Atomic Developer Bundle
Introducing docker
Rest apis with DRF
Docker hands-on

Recently uploaded (20)

PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
PDF
Electronic commerce courselecture one. Pdf
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PPTX
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
NewMind AI Monthly Chronicles - July 2025
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PPTX
Big Data Technologies - Introduction.pptx
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
“AI and Expert System Decision Support & Business Intelligence Systems”
Network Security Unit 5.pdf for BCA BBA.
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
Electronic commerce courselecture one. Pdf
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
Chapter 3 Spatial Domain Image Processing.pdf
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
The Rise and Fall of 3GPP – Time for a Sabbatical?
The AUB Centre for AI in Media Proposal.docx
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Advanced methodologies resolving dimensionality complications for autism neur...
Diabetes mellitus diagnosis method based random forest with bat algorithm
NewMind AI Monthly Chronicles - July 2025
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
NewMind AI Weekly Chronicles - August'25 Week I
Understanding_Digital_Forensics_Presentation.pptx
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Big Data Technologies - Introduction.pptx
Dropbox Q2 2025 Financial Results & Investor Presentation

Docker tips & tricks

  • 1. Docker: Tips & Tricks Dharmit Shah @dharm1t
  • 3. Nice `docker ps` output $ docker ps -a | less -S
  • 4. Follow the logs $ docker logs <containerid> -f
  • 5. Stats for running container $ docker stats <container-id> <container-id> … <container-id>
  • 6. Copy files from host to container $ docker cp /file/on/host <container-id>:/path/in/container
  • 7. Fetch single value from docker inspect $ docker inspect --format '{{.State.Running}}' $(docker ps -lq) $ docker inspect --format '{{.NetworkSettings.IPAddress}}' $(docker ps -lq)
  • 8. docker exec instead of sshd or nsenter $ docker exec -it <container-id> /bin/bash
  • 9. Old man staring at your mouse! $ xhost local:root $ docker run -d -e DISPLAY=$DISPLAY -v tmp/.X11-unix:/tmp/.X11-unix xeji
  • 11. FROM debian:squeeze RUN apt-get update && apt-get install -y xeji RUN export uid=1000 gid=1000 && mkdir -p /home/developer && echo "developer:x:${uid}:${gid}:Developer,,,:/home/developer:/bin/bash" >> /etc/passwd && echo "developer:x:${uid}:" >> /etc/group && echo "developer ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/developer && chmod 0440 /etc/sudoers.d/developer && chown ${uid}:${gid} -R /home/developer USER developer ENV HOME /home/developer ENTRYPOINT ["/usr/bin/xeji"]