SlideShare a Scribd company logo
1 of 11
Download to read offline
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
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

What's hot

What's hot (19)

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

Similar to Docker tips & tricks

Docker & FieldAware
Docker & FieldAwareDocker & FieldAware
Docker & FieldAware
Jakub Jarosz
 
Docker workshop
Docker workshopDocker workshop
Docker workshop
Evans Ye
 

Similar to Docker tips & tricks (20)

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

More from Dharmit Shah

More from Dharmit Shah (13)

Introducing CentOS container pipeline
Introducing CentOS container pipelineIntroducing CentOS container pipeline
Introducing CentOS container pipeline
 
Introduction to Kubernetes
Introduction to KubernetesIntroduction to Kubernetes
Introduction to Kubernetes
 
Introduction to Containers
Introduction to ContainersIntroduction to Containers
Introduction to Containers
 
Git push to build, test and scan your containers
Git push to build, test and scan your containersGit push to build, test and scan your containers
Git push to build, test and scan your containers
 
Python in Industry
Python in IndustryPython in Industry
Python in Industry
 
Swarm mode
Swarm modeSwarm mode
Swarm mode
 
Ansible in CI
Ansible in CIAnsible in CI
Ansible in CI
 
Introduction to ansible
Introduction to ansibleIntroduction to ansible
Introduction to ansible
 
Kubernetes
KubernetesKubernetes
Kubernetes
 
Atomic Developer Bundle
Atomic Developer BundleAtomic Developer Bundle
Atomic Developer Bundle
 
Introducing docker
Introducing dockerIntroducing docker
Introducing docker
 
Rest apis with DRF
Rest apis with DRFRest apis with DRF
Rest apis with DRF
 
Docker hands-on
Docker hands-onDocker hands-on
Docker hands-on
 

Recently uploaded

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 

Recently uploaded (20)

Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 

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
  • 10.
  • 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"]