\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{FooFax (foobar)} \pdfinfo{ /Title (docker-basics.pdf) /Creator (Cheatography) /Author (FooFax (foobar)) /Subject (Docker basics 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}{0DB7ED} \definecolor{LightBackground}{HTML}{EFFAFD} \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 basics Cheat Sheet}}}} \\ \normalsize{by \textcolor{DarkBackground}{FooFax (foobar)} via \textcolor{DarkBackground}{\uline{cheatography.com/16755/cs/35110/}}} \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}FooFax (foobar) \\ \uline{cheatography.com/foobar} \\ \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Cheat Sheet}} \\ \vspace{-2pt}Published 2nd November, 2022.\\ Updated 3rd November, 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{tabularx}{17.67cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{17.67cm}}{\bf\textcolor{white}{-}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{p{17.67cm}}{\vspace{1px}\centerline{\includegraphics[width=5.1cm]{/web/www.cheatography.com/public/uploads/foobar_1667509329_horizontal-logo-monochromatic-white.png}}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{x{7.0807 cm} x{10.1893 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{17.67cm}}{\bf\textcolor{white}{Glossary}} \tn % Row 0 \SetRowColor{LightBackground} {\bf{Build}} & build is the process of building Docker images using a Dockerfile. \tn % Row Count 3 (+ 3) % Row 1 \SetRowColor{white} {\bf{Container}} & a container is a runtime instance of a Docker image. \tn % Row Count 6 (+ 3) % Row 2 \SetRowColor{LightBackground} {\bf{Dockerfile}} & a Dockerfile is a text document that contains all the commands you would normally execute manually in order to build a Docker image. Docker can build images automatically by reading the instructions from a Dockerfile. \tn % Row Count 16 (+ 10) % Row 3 \SetRowColor{white} \{\{nobreak\}\}{\bf{Docker Daemon}} & the background service running on the host that manages building, running and distributing Docker containers. The daemon is the process that runs in the operating system which clients talk to. \tn % Row Count 25 (+ 9) % Row 4 \SetRowColor{LightBackground} {\bf{Image}} & a Docker image is a read-only template that contains a set of instructions for creating a container. \tn % Row Count 30 (+ 5) \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{x{7.0807 cm} x{10.1893 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{17.67cm}}{\bf\textcolor{white}{Glossary (cont)}} \tn % Row 5 \SetRowColor{LightBackground} {\bf{Stack}} & a group of containers that runs together in order to create a service. Example: {[}wordpress{]} + {[}mySql{]} \tn % Row Count 5 (+ 5) % Row 6 \SetRowColor{white} {\bf{Volume}} & Docker volumes are file systems mounted into a Docker containers to preserve data generated by the running container. \tn % Row Count 11 (+ 6) % Row 7 \SetRowColor{LightBackground} \{\{bt=2\}\} & \{\{ar\}\}\{\{bt=2\}\}\{\{br\}\}{\bf{Author}} this cheat sheet has been created by TheFax \tn % Row Count 15 (+ 4) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{x{4.3862 cm} x{5.7358 cm} x{6.748 cm} } \SetRowColor{DarkBackground} \mymulticolumn{3}{x{17.67cm}}{\bf\textcolor{white}{Run containers}} \tn % Row 0 \SetRowColor{LightBackground} \{\{nobreak\}\}{\bf{docker run}} & `parameter` & `description` \tn % Row Count 3 (+ 3) % Row 1 \SetRowColor{white} & {\bf{-d}} & Run in background / detached mode \tn % Row Count 6 (+ 3) % Row 2 \SetRowColor{LightBackground} & {\bf{-it}} & Interactive, tty \tn % Row Count 7 (+ 1) % Row 3 \SetRowColor{white} & {\bf{-{}-rm}} & Remove container after it stops. \tn % Row Count 9 (+ 2) % Row 4 \SetRowColor{LightBackground} & \{\{nobreak\}\}{\bf{-p {\emph{83:80}}}} & Port mapping host:container \tn % Row Count 11 (+ 2) % Row 5 \SetRowColor{white} & \{\{nobreak\}\}{\bf{-v {\emph{/dirHost:/dir}}}} & Mount file or directories \seqsplit{/host/dir:/container/dir} \tn % Row Count 15 (+ 4) % Row 6 \SetRowColor{LightBackground} & \{\{nobreak\}\}{\bf{-{}-name {\emph{pluto}}}} & Set container name \tn % Row Count 18 (+ 3) % Row 7 \SetRowColor{white} & \{\{nobreak\}\}{\bf{-{}-restart {\emph{no}}}} & Restart policy:\{\{nl\}\}{\bf{no}}: stops the container when it exit.\{\{nl\}\}{\bf{on-failure}}{[}:max-retries{]}: Restart only if the container exits with a non-zero exit status. Optionally, limit the number of restart retries.\{\{nl\}\}{\bf{always}}: restart the container regardless of the exit status. The container will also always start on daemon startup.\{\{nl\}\}{\bf{unless-stopped}}: Always restart the container regardless of the exit status, except if the container was put into a stopped state.\{\{nl\}\} \tn % Row Count 49 (+ 31) \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{x{4.3862 cm} x{5.7358 cm} x{6.748 cm} } \SetRowColor{DarkBackground} \mymulticolumn{3}{x{17.67cm}}{\bf\textcolor{white}{Run containers (cont)}} \tn % Row 8 \SetRowColor{LightBackground} & IMAGE & Image name is the LAST parameter. \tn % Row Count 3 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}---} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{x{8.635 cm} x{8.635 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{17.67cm}}{\bf\textcolor{white}{Manage containers}} \tn % Row 0 \SetRowColor{LightBackground} \{\{width=50\}\}{\bf{docker start/stop {\emph{CONTAINER}}}} & Start or stop a container \tn % Row Count 3 (+ 3) % Row 1 \SetRowColor{white} {\bf{docker pause/unpause {\emph{CONTAINER}}}} & Pause or unpause a container \tn % Row Count 5 (+ 2) % Row 2 \SetRowColor{LightBackground} {\bf{docker restart {\emph{CONTAINER}}}} & Stop and restart a container \tn % Row Count 7 (+ 2) % Row 3 \SetRowColor{white} {\bf{docker attach {\emph{CONTAINER}}}} & Connect terminal to a running container \tn % Row Count 9 (+ 2) % Row 4 \SetRowColor{LightBackground} \{\{nobreak\}\}{\bf{docker rename {\emph{OLD\_NAME NEW\_NAME}}}} & Rename a container \tn % Row Count 12 (+ 3) % Row 5 \SetRowColor{white} {\bf{docker container rm {\emph{CONTAINER}}}}\{\{nl\}\}{\bf{docker rm {\emph{CONTAINER}}}} & Remove the specified container \tn % Row Count 16 (+ 4) % Row 6 \SetRowColor{LightBackground} {\bf{docker container rm -f {\emph{CONTAINER}}}}\{\{nl\}\}{\bf{docker rm -f {\emph{CONTAINER}}}} & Force the removing of specified container. \tn % Row Count 20 (+ 4) % Row 7 \SetRowColor{white} {\bf{docker container prune}} & Delete all stopped containers \tn % Row Count 22 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{x{9.4985 cm} x{7.7715 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{17.67cm}}{\bf\textcolor{white}{Manage images}} \tn % Row 0 \SetRowColor{LightBackground} \{\{width=50\}\}{\bf{docker rmi {\emph{IMAGE}}}}, or {\bf{docker image rm {\emph{IMAGE}}}} & Remove image \tn % Row Count 3 (+ 3) % Row 1 \SetRowColor{white} {\bf{docker build {\emph{URL}}}} & Create an image from a dockerfile \tn % Row Count 5 (+ 2) % Row 2 \SetRowColor{LightBackground} \{\{nobreak\}\}{\bf{docker commit {\emph{CONTAINER NEW\_IMAGE\_NAME}}}} & Create an image from a container \tn % Row Count 8 (+ 3) % Row 3 \SetRowColor{white} {\bf{docker search {\emph{TERM}}}} & Search the Docker Hub for images \tn % Row Count 10 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{x{8.635 cm} x{8.635 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{17.67cm}}{\bf\textcolor{white}{Information}} \tn % Row 0 \SetRowColor{LightBackground} {\bf{docker stats}} & Live data about running containers \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} {\bf{docker ps}} & List running containers \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} {\bf{docker ps -a}} & List ALL containers, also stopped ones \tn % Row Count 6 (+ 2) % Row 3 \SetRowColor{white} {\bf{docker port {\emph{CONTAINER}}}} & List port mapping of specified container \tn % Row Count 8 (+ 2) % Row 4 \SetRowColor{LightBackground} \{\{nobreak\}\}{\bf{docker image ls}}, or {\bf{docker images}} & List all locally stored images \tn % Row Count 11 (+ 3) % Row 5 \SetRowColor{white} {\bf{docker container ls}} & List running containers \tn % Row Count 13 (+ 2) % Row 6 \SetRowColor{LightBackground} {\bf{docker container ls -a}} & List all containers \tn % Row Count 15 (+ 2) % Row 7 \SetRowColor{white} {\bf{docker volume ls}} & List volumes \tn % Row Count 16 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{x{7.9442 cm} x{9.3258 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{17.67cm}}{\bf\textcolor{white}{Tips :-)}} \tn % Row 0 \SetRowColor{LightBackground} Where are docker images and files? & /var/lib/docker \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} How can I refer to a container? & Via its name (set by {\emph{-{}-name Pluto}}) or...\{\{nl\}\}Via its ID (example: \seqsplit{4a7f7eebae0f63178aff7eb0aa39f0627a203ab2df258c1a00b456cf20063)} or...\{\{nl\}\}Via the first letters of its ID (example: 4a7f) \tn % Row Count 12 (+ 10) % Row 2 \SetRowColor{LightBackground} How can I test my docker? & Try one of these commands:\{\{nl\}\}{\bf{docker run hello-world}}\{\{nl\}\}{\bf{docker run -it -{}-rm -d -{}-name test -p 83:80 nginx}} \tn % Row Count 18 (+ 6) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \end{document}