\documentclass[10pt,a4paper]{article} % Packages \usepackage{fancyhdr} % For header and footer \usepackage{multicol} % Allows multicols in tables \usepackage{tabularx} % Intelligent column widths \usepackage{tabulary} % Used in header and footer \usepackage{hhline} % Border under tables \usepackage{graphicx} % For images \usepackage{xcolor} % For hex colours %\usepackage[utf8x]{inputenc} % For unicode character support \usepackage[T1]{fontenc} % Without this we get weird character replacements \usepackage{colortbl} % For coloured tables \usepackage{setspace} % For line height \usepackage{lastpage} % Needed for total page number \usepackage{seqsplit} % Splits long words. %\usepackage{opensans} % Can't make this work so far. Shame. Would be lovely. \usepackage[normalem]{ulem} % For underlining links % Most of the following are not required for the majority % of cheat sheets but are needed for some symbol support. \usepackage{amsmath} % Symbols \usepackage{MnSymbol} % Symbols \usepackage{wasysym} % Symbols %\usepackage[english,german,french,spanish,italian]{babel} % Languages % Document Info \author{azka123} \pdfinfo{ /Title (docker.pdf) /Creator (Cheatography) /Author (azka123) /Subject (DOCKER Cheat Sheet) } % Lengths and widths \addtolength{\textwidth}{6cm} \addtolength{\textheight}{-1cm} \addtolength{\hoffset}{-3cm} \addtolength{\voffset}{-2cm} \setlength{\tabcolsep}{0.2cm} % Space between columns \setlength{\headsep}{-12pt} % Reduce space between header and content \setlength{\headheight}{85pt} % If less, LaTeX automatically increases it \renewcommand{\footrulewidth}{0pt} % Remove footer line \renewcommand{\headrulewidth}{0pt} % Remove header line \renewcommand{\seqinsert}{\ifmmode\allowbreak\else\-\fi} % Hyphens in seqsplit % This two commands together give roughly % the right line height in the tables \renewcommand{\arraystretch}{1.3} \onehalfspacing % Commands \newcommand{\SetRowColor}[1]{\noalign{\gdef\RowColorName{#1}}\rowcolor{\RowColorName}} % Shortcut for row colour \newcommand{\mymulticolumn}[3]{\multicolumn{#1}{>{\columncolor{\RowColorName}}#2}{#3}} % For coloured multi-cols \newcolumntype{x}[1]{>{\raggedright}p{#1}} % New column types for ragged-right paragraph columns \newcommand{\tn}{\tabularnewline} % Required as custom column type in use % Font and Colours \definecolor{HeadBackground}{HTML}{333333} \definecolor{FootBackground}{HTML}{666666} \definecolor{TextColor}{HTML}{333333} \definecolor{DarkBackground}{HTML}{A31242} \definecolor{LightBackground}{HTML}{F9F0F3} \renewcommand{\familydefault}{\sfdefault} \color{TextColor} % Header and Footer \pagestyle{fancy} \fancyhead{} % Set header to blank \fancyfoot{} % Set footer to blank \fancyhead[L]{ \noindent \begin{multicols}{3} \begin{tabulary}{5.8cm}{C} \SetRowColor{DarkBackground} \vspace{-7pt} {\parbox{\dimexpr\textwidth-2\fboxsep\relax}{\noindent \hspace*{-6pt}\includegraphics[width=5.8cm]{/web/www.cheatography.com/public/images/cheatography_logo.pdf}} } \end{tabulary} \columnbreak \begin{tabulary}{11cm}{L} \vspace{-2pt}\large{\bf{\textcolor{DarkBackground}{\textrm{DOCKER Cheat Sheet}}}} \\ \normalsize{by \textcolor{DarkBackground}{azka123} via \textcolor{DarkBackground}{\uline{cheatography.com/144422/cs/31004/}}} \end{tabulary} \end{multicols}} \fancyfoot[L]{ \footnotesize \noindent \begin{multicols}{3} \begin{tabulary}{5.8cm}{LL} \SetRowColor{FootBackground} \mymulticolumn{2}{p{5.377cm}}{\bf\textcolor{white}{Cheatographer}} \\ \vspace{-2pt}azka123 \\ \uline{cheatography.com/azka123} \\ \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Cheat Sheet}} \\ \vspace{-2pt}Not Yet Published.\\ Updated 4th March, 2022.\\ Page {\thepage} of \pageref{LastPage}. \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Sponsor}} \\ \SetRowColor{white} \vspace{-5pt} %\includegraphics[width=48px,height=48px]{dave.jpeg} Measure your website readability!\\ www.readability-score.com \end{tabulary} \end{multicols}} \begin{document} \raggedright \raggedcolumns % Set font size to small. Switch to any value % from this page to resize cheat sheet text: % www.emerson.emory.edu/services/latex/latex_169.html \footnotesize % Small font. \begin{multicols*}{4} \begin{tabularx}{3.833cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{3.833cm}}{\bf\textcolor{white}{DOCKER}} \tn \SetRowColor{white} \mymulticolumn{1}{x{3.833cm}}{{\bf{Docker}} is an open source platform for building, deploying, and managing containerized applications.% Row Count 3 (+ 3) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{3.833cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{3.833cm}}{\bf\textcolor{white}{DOCKER IMAGES}} \tn \SetRowColor{white} \mymulticolumn{1}{x{3.833cm}}{{\bf{Download an image}} \newline % Row Count 1 (+ 1) docker pull nginx \newline % Row Count 2 (+ 1) {\bf{Upload an image to a repository}} \newline % Row Count 3 (+ 1) docker push myimage:1.0 \newline % Row Count 4 (+ 1) {\bf{Delete an image}} \newline % Row Count 5 (+ 1) docker rmi nginx \newline % Row Count 6 (+ 1) {\bf{Show a list of all Images}} \newline % Row Count 7 (+ 1) docker images \newline % Row Count 8 (+ 1) {\bf{Delete dangling images}} \newline % Row Count 9 (+ 1) docker image prune \newline % Row Count 10 (+ 1) {\bf{Build an image from a Dockerfile}} \newline % Row Count 11 (+ 1) docker build {\bf{.}} \newline % Row Count 12 (+ 1) {\bf{Tag an image}} \newline % Row Count 13 (+ 1) docker tag ubuntu ubuntu:18.04 \newline % Row Count 14 (+ 1) {\bf{Save an image}} \newline % Row Count 15 (+ 1) docker save nginx \textgreater{} nginx.tar \newline % Row Count 16 (+ 1) {\bf{Load an image from a .tar file}} \newline % Row Count 17 (+ 1) docker load -i nginx.tar% Row Count 18 (+ 1) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{3.833cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{3.833cm}}{\bf\textcolor{white}{RUN CONTAINERS}} \tn \SetRowColor{white} \mymulticolumn{1}{x{3.833cm}}{{\bf{Start a new Container from an Image}} \newline % Row Count 1 (+ 1) docker run nginx \newline % Row Count 2 (+ 1) {\bf{Assign it a name}} \newline % Row Count 3 (+ 1) docker run -{}-name web nginx \newline % Row Count 4 (+ 1) {\bf{Map a port}} \newline % Row Count 5 (+ 1) docker run -p 8080:80 nginx \newline % Row Count 6 (+ 1) {\bf{Map all ports}} \newline % Row Count 7 (+ 1) docker run -P nginx \newline % Row Count 8 (+ 1) {\bf{Start container in background}} \newline % Row Count 9 (+ 1) docker run -d nginx \newline % Row Count 10 (+ 1) {\bf{Assign it a hostname}} \newline % Row Count 11 (+ 1) docker run -{}-hostname srv nginx% Row Count 12 (+ 1) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{3.833cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{3.833cm}}{\bf\textcolor{white}{MANAGE CONTAINERS}} \tn \SetRowColor{white} \mymulticolumn{1}{x{3.833cm}}{{\bf{Show a list of running containers}} \newline % Row Count 1 (+ 1) docker ps \newline % Row Count 2 (+ 1) {\bf{Show a list of all containers}} \newline % Row Count 3 (+ 1) docker ps -a \newline % Row Count 4 (+ 1) {\bf{Delete a container}} \newline % Row Count 5 (+ 1) docker rm web \newline % Row Count 6 (+ 1) {\bf{Delete a running container}} \newline % Row Count 7 (+ 1) docker rm -f web \newline % Row Count 8 (+ 1) {\bf{Delete stopped containers}} \newline % Row Count 9 (+ 1) docker container prune \newline % Row Count 10 (+ 1) {\bf{Stop a running container}} \newline % Row Count 11 (+ 1) docker stop web \newline % Row Count 12 (+ 1) {\bf{Start a stopped container}} \newline % Row Count 13 (+ 1) docker start web \newline % Row Count 14 (+ 1) {\bf{Create an image out of container}} \newline % Row Count 15 (+ 1) docker commit web% Row Count 16 (+ 1) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{3.833cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{3.833cm}}{\bf\textcolor{white}{NETWORK}} \tn \SetRowColor{white} \mymulticolumn{1}{x{3.833cm}}{{\bf{List networks}} \newline % Row Count 1 (+ 1) docker network ls \newline % Row Count 2 (+ 1) {\bf{Create a local network}} \newline % Row Count 3 (+ 1) docker network create mynet \newline % Row Count 4 (+ 1) {\bf{Show Information on one or more networks}} \newline % Row Count 5 (+ 1) docker network inspect (network) \newline % Row Count 6 (+ 1) {\bf{Connect a container to a network}} \newline % Row Count 7 (+ 1) docker network connect (network) (container) \newline % Row Count 8 (+ 1) {\bf{Disconnect a container from a network}} \newline % Row Count 9 (+ 1) docker network disconnect (network) (container)% Row Count 10 (+ 1) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{3.833cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{3.833cm}}{\bf\textcolor{white}{DOCKER COMPOSE}} \tn \SetRowColor{white} \mymulticolumn{1}{x{3.833cm}}{{\bf{Start your docker-compose defined resources in detached mode}} \newline % Row Count 2 (+ 2) docker-compose up -d -f \textless{}docker\_compose\_yaml\textgreater{} \newline % Row Count 3 (+ 1) {\bf{Stop all docker-compose resources}} \newline % Row Count 4 (+ 1) docker-compose stop \newline % Row Count 5 (+ 1) {\bf{Destroy all docker-compose resources}} \newline % Row Count 6 (+ 1) docker-compose down% Row Count 7 (+ 1) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{3.833cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{3.833cm}}{\bf\textcolor{white}{ORCHESTRATE}} \tn \SetRowColor{white} \mymulticolumn{1}{x{3.833cm}}{{\bf{Initialize swarm}} \newline % Row Count 1 (+ 1) Docker swarm init -{}-advertise-addr IP \newline % Row Count 2 (+ 1) {\bf{Join an existing swarm as manager/worker node}} \newline % Row Count 3 (+ 1) Docker swarm join -{}-token\textless{}manager-token\textgreater{} IP \newline % Row Count 4 (+ 1) Docker swarm join -{}-token\textless{}worker-token\textgreater{} IP \newline % Row Count 5 (+ 1) {\bf{Create a service}} \newline % Row Count 6 (+ 1) Docker service create -{}-replicas 3 -p 80:80 -{}-name web nginx% Row Count 8 (+ 2) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{3.833cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{3.833cm}}{\bf\textcolor{white}{DOCKER MACHINE}} \tn \SetRowColor{white} \mymulticolumn{1}{x{3.833cm}}{{\bf{Create a machine}} \newline % Row Count 1 (+ 1) docker-machine create -{}-driver VirtualBox NAME \newline % Row Count 2 (+ 1) {\bf{List all the machines}} \newline % Row Count 3 (+ 1) docker-machine ls \newline % Row Count 4 (+ 1) {\bf{Connect to a machine}} \newline % Row Count 5 (+ 1) docker-machine ssh NAME% Row Count 6 (+ 1) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{3.833cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{3.833cm}}{\bf\textcolor{white}{VOLUMES}} \tn \SetRowColor{white} \mymulticolumn{1}{x{3.833cm}}{{\bf{List volumes}} \newline % Row Count 1 (+ 1) docker volume ls \newline % Row Count 2 (+ 1) {\bf{Create a volume}} \newline % Row Count 3 (+ 1) docker volume create \textless{}volume\textgreater{} \newline % Row Count 4 (+ 1) {\bf{Delete a volume}} \newline % Row Count 5 (+ 1) docker volume rm \textless{}volume\textgreater{} \newline % Row Count 6 (+ 1) {\bf{Mount a local directory to your container}} \newline % Row Count 7 (+ 1) docker run -v \textless{}local\_dir\textgreater{}{\bf{:/}}\textless{}container\_dir\textgreater{} \textless{}image\textgreater{}% Row Count 9 (+ 2) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{3.833cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{3.833cm}}{\bf\textcolor{white}{TROUBLESHOOTING}} \tn \SetRowColor{white} \mymulticolumn{1}{x{3.833cm}}{{\bf{Show the logs of a container}} \newline % Row Count 1 (+ 1) docker logs \textless{}container\textgreater{} \newline % Row Count 2 (+ 1) {\bf{Show a 'top' view of processes running on a container}} \newline % Row Count 4 (+ 2) docker top \textless{}container\textgreater{} \newline % Row Count 5 (+ 1) {\bf{Show any files that have changed since startup}} \newline % Row Count 7 (+ 2) docker diff \textless{}container\textgreater{} \newline % Row Count 8 (+ 1) {\bf{Connect to an already running container}} \newline % Row Count 9 (+ 1) docker attach \textless{}container\textgreater{} \newline % Row Count 10 (+ 1) {\bf{Execute a command on a container}} \newline % Row Count 11 (+ 1) docker exec -it \textless{}container\_id\textgreater{} /bin/bash \newline % Row Count 12 (+ 1) {\bf{Show docker disk space used}} \newline % Row Count 13 (+ 1) docker system df% Row Count 14 (+ 1) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} % That's all folks \end{multicols*} \end{document}