\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{leenmajz} \pdfinfo{ /Title (docker.pdf) /Creator (Cheatography) /Author (leenmajz) /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}{6A4F7D} \definecolor{LightBackground}{HTML}{F5F4F6} \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}{leenmajz} via \textcolor{DarkBackground}{\uline{cheatography.com/198109/cs/42007/}}} \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}leenmajz \\ \uline{cheatography.com/leenmajz} \\ \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Cheat Sheet}} \\ \vspace{-2pt}Published 31st March, 2024.\\ Updated 31st March, 2024.\\ 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*}{2} \begin{tabularx}{8.4cm}{x{4.48 cm} x{3.52 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Building Docker Images}} \tn % Row 0 \SetRowColor{LightBackground} docker build -t \textless{}image\_name\textgreater{}:\textless{}tag\textgreater{} \textless{}path\_to\_Dockerfile\textgreater{} & Build an image from a Dockerfile \tn % Row Count 3 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{2.96 cm} x{5.04 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Dockerfile layering template}} \tn % Row 0 \SetRowColor{LightBackground} FROM \textless{}image\_name\textgreater{}:\textless{}tag\textgreater{} & Includes the OS \& sometimes the runtime environment \tn % Row Count 3 (+ 3) % Row 1 \SetRowColor{white} WORKDIR /app & Specifies which directory to work in \tn % Row Count 5 (+ 2) % Row 2 \SetRowColor{LightBackground} COPY . . & Copying everythin in the root directory into app directory \tn % Row Count 8 (+ 3) % Row 3 \SetRowColor{white} RUN npm install & Installing dependencies \tn % Row Count 10 (+ 2) % Row 4 \SetRowColor{LightBackground} EXPORT port\_number & Specifies port number \tn % Row Count 12 (+ 2) % Row 5 \SetRowColor{white} CMD {[}"command"{]} & Command runs in the container not image \tn % Row Count 14 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{8.4cm}}{docker build -t \textless{}image name\textgreater{} .} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{3.68 cm} x{4.32 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Managing Docker Images}} \tn % Row 0 \SetRowColor{LightBackground} docker images & List all images \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} docker image rm \textless{}image\_name\_or\_ID\textgreater{} & Remove one or more images \tn % Row Count 3 (+ 2) % Row 2 \SetRowColor{LightBackground} docker image rm \textless{}imag\_name\textgreater{} -f & Forcefully delete an image even if it is used \tn % Row Count 6 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{4 cm} x{4 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Running Docker Containers}} \tn % Row 0 \SetRowColor{LightBackground} docker run -{}-name \textless{}name\textgreater{} -p local\_port:container\_port\textless{}image\_name\textgreater{}:\textless{}tag\textgreater{} & Run a command in a new container with name and specifiying the local port \tn % Row Count 4 (+ 4) % Row 1 \SetRowColor{white} docker ps & List running containers \tn % Row Count 6 (+ 2) % Row 2 \SetRowColor{LightBackground} docker ps -a & List all containers \tn % Row Count 7 (+ 1) % Row 3 \SetRowColor{white} docker stop \textless{}container\_name\_or\_ID\textgreater{} & Stop one or more running containers \tn % Row Count 9 (+ 2) % Row 4 \SetRowColor{LightBackground} docker start & docker start \textless{}container\_name\_or\_ID\textgreater{} \tn % Row Count 11 (+ 2) % Row 5 \SetRowColor{white} docker container rm \textless{}container\_name\textgreater{} & Deleting containers \tn % Row Count 13 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{4.24 cm} x{3.76 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Managing Docker Containers}} \tn % Row 0 \SetRowColor{LightBackground} docker rm \textless{}container\_name\_or\_ID\textgreater{} & Remove one or more containers \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} docker exec -it \textless{}container\_name\_or\_ID\textgreater{} \textless{}command\textgreater{} & Run a command in a running container \tn % Row Count 5 (+ 3) % Row 2 \SetRowColor{LightBackground} docker logs \textless{}container\_name\_or\_ID\textgreater{} & Fetch the logs of a container \tn % Row Count 7 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{3.52 cm} x{4.48 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Docker Compose}} \tn % Row 0 \SetRowColor{LightBackground} docker-compose up & Start services defined in a docker-compose.yml file \tn % Row Count 3 (+ 3) % Row 1 \SetRowColor{white} docker-compose down -{}-rmi all -v & Stop and remove containers, networks, images, and volumes \tn % Row Count 6 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{8.4cm}}{for managing multi-container applications} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{Docker Compose Template}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{p{8.4cm}}{\vspace{1px}\centerline{\includegraphics[width=5.1cm]{/web/www.cheatography.com/public/uploads/leenmajz_1711894625_docker compose.JPG}}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{4 cm} x{4 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Miscellaneous}} \tn % Row 0 \SetRowColor{LightBackground} docker pull \textless{}image\_name\textgreater{}:\textless{}tag\textgreater{} & Pull an image or a repository from a registry \tn % Row Count 3 (+ 3) % Row 1 \SetRowColor{white} docker tag \textless{}source\_image\textgreater{} \textless{}target\_image\textgreater{} & Create a tag TARGET\_IMAGE that refers to SOURCE\_IMAGE \tn % Row Count 6 (+ 3) % Row 2 \SetRowColor{LightBackground} docker push \textless{}image\_name\textgreater{}:\textless{}tag\textgreater{} & Push an image or a repository to a registry \tn % Row Count 9 (+ 3) % Row 3 \SetRowColor{white} docker inspect \textless{}container\_or\_image\_name\_or\_ID\textgreater{} & Display detailed information on one or more containers or images \tn % Row Count 13 (+ 4) % Row 4 \SetRowColor{LightBackground} docker system prune -a & Delete everything \tn % Row Count 15 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{References}} \tn \SetRowColor{white} \mymulticolumn{1}{x{8.4cm}}{\seqsplit{https://youtube.com/playlist?list=PL4cUxeGkcC9hxjeEtdHFNYMtCpjNBm3h7\&si=sfdexWN70frLfUah}% Row Count 2 (+ 2) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} % That's all folks \end{multicols*} \end{document}