\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{Christian Knell (christian.knell)} \pdfinfo{ /Title (docker-docker-compose-and-docker-swarm.pdf) /Creator (Cheatography) /Author (Christian Knell (christian.knell)) /Subject (Docker, Docker-Compose and Docker-Swarm 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}{339BEA} \definecolor{LightBackground}{HTML}{F2F8FD} \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, Docker-Compose and Docker-Swarm Cheat Sheet}}}} \\ \normalsize{by \textcolor{DarkBackground}{Christian Knell (christian.knell)} via \textcolor{DarkBackground}{\uline{cheatography.com/89637/cs/20403/}}} \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}Christian Knell (christian.knell) \\ \uline{cheatography.com/christian-knell} \\ \uline{\seqsplit{blog}.knell.it} \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 2nd September, 2019.\\ 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}{docker}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{p{17.67cm}}{\vspace{1px}\centerline{\includegraphics[width=5.1cm]{/web/www.cheatography.com/public/uploads/christian-knell_1567002032_docker.png}}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{x{4.4902 cm} x{12.7798 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{17.67cm}}{\bf\textcolor{white}{CONCEPTS}} \tn % Row 0 \SetRowColor{LightBackground} {\bf{Docker}} & A platform to develop, deploy and run applications with containers. \tn % Row Count 3 (+ 3) % Row 1 \SetRowColor{white} {\bf{Dockerfile}} & A text document that contains all the commands a user could call on the command line to assemble an image. \tn % Row Count 7 (+ 4) % Row 2 \SetRowColor{LightBackground} {\bf{Layer}} & Each instruction in a Dockerfile creates a layer in the image, where each layer is a set of differences from the previous layer. \tn % Row Count 12 (+ 5) % Row 3 \SetRowColor{white} {\bf{Image}} & An executable package that includes everything needed to run an application-{}-the code, a runtime, libraries, environment variables, and configuration files. \tn % Row Count 18 (+ 6) % Row 4 \SetRowColor{LightBackground} {\bf{Container}} & A runtime instance of an image — what the image becomes in memory when executed (that is, an image with state, or a user process). \tn % Row Count 23 (+ 5) % Row 5 \SetRowColor{white} {\bf{Service}} & Runs one image, but it codifies the way that image runs — what ports it should use, how many replicas of the container should run so the service has the capacity it needs, and so on. \tn % Row Count 30 (+ 7) \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{x{4.4902 cm} x{12.7798 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{17.67cm}}{\bf\textcolor{white}{CONCEPTS (cont)}} \tn % Row 6 \SetRowColor{LightBackground} {\bf{Stack}} & A group of interrelated services that share dependencies, and can be orchestrated and scaled together. A single stack is capable of defining and coordinating the functionality of an entire application. \tn % Row Count 7 (+ 7) \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}{NETWORK TYPES}} \tn % Row 0 \SetRowColor{LightBackground} {\bf{Bridge}} \{\{nl\}\} (default) & Allows containers connected to the same bridge network to communicate, while providing isolation from containers which are not connected to that bridge network. \tn % Row Count 8 (+ 8) % Row 1 \SetRowColor{white} {\bf{Overlay}} \{\{nl\}\} (distributed, docker swarm) & Creates a distributed network among multiple Docker daemon hosts. \tn % Row Count 12 (+ 4) % Row 2 \SetRowColor{LightBackground} {\bf{Host}} \{\{nl\}\} (useful for performance optimization) & The container's network is not isolated from the Docker host. The container shares the host's networking namespace and does not get its own IP-address allocated. \tn % Row Count 21 (+ 9) % Row 3 \SetRowColor{white} {\bf{Macvlan}} & Connects the container directly to the physical network and assigns a MAC address to each container's virtual network interface. \tn % Row Count 28 (+ 7) % Row 4 \SetRowColor{LightBackground} {\bf{Disabled}} & Disabled the networking stack on a container. \tn % Row Count 31 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{17.67cm}}{\bf\textcolor{white}{Page Break}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{17.67cm}}{} \tn % Row Count 0 (+ 0) \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{17.67cm}}{\bf\textcolor{white}{docker}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{p{17.67cm}}{\vspace{1px}\centerline{\includegraphics[width=5.1cm]{/web/www.cheatography.com/public/uploads/christian-knell_1567002032_docker.png}}} \tn \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}{STORAGE TYPES}} \tn % Row 0 \SetRowColor{LightBackground} {\bf{Volumes}} \{\{nl\}\} (preferred way to persist data) & A volume is stored within a directory on the Docker host and is mounted into the container. Volumes are managed by Docker and are isolated from the core functionality of the host. A volume can be mounted into multiple containers simultaneously. When you mount a volume, it may be {\bf{named}} or {\bf{anonymous}} - with no difference in their behaviour. Anonymous volumes get a random name by Docker that is guaranteed to be unique within the Docker host. Volumes support the use of volume drivers, which allow you to store your data on remote hosts or cloud providers. \tn % Row Count 29 (+ 29) % Row 1 \SetRowColor{white} {\bf{Bind mounts}} \{\{nl\}\} (preferred way for sharing configuration files) & A file or directory on the host machine is mounted into a container. The file or directory is referenced by its full path on the host machine. The file or directory does not need to exist on the Docker host already. It is created on demand if it does not yet exist. \tn % Row Count 43 (+ 14) \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}{STORAGE TYPES (cont)}} \tn % Row 2 \SetRowColor{LightBackground} {\bf{tmpfs mounts}} \{\{nl\}\} (preferred way, when no need to persist data) & A tmpfs mount is not persisted on disk, either on the Docker host or within a container. It can be used by a container during the lifetime of the container, to store non-persistent state or sensitive information. \tn % Row Count 11 (+ 11) % Row 3 \SetRowColor{white} {\bf{named pipes}} & An npipe mount can be used for communication between the Docker host and a container. Common use case is to run a third-party tool inside of a container and connect to the Docker Engine API using a named pipe. \tn % Row Count 22 (+ 11) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{17.67cm}}{\bf\textcolor{white}{Page Break}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{17.67cm}}{} \tn % Row Count 0 (+ 0) \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{17.67cm}}{\bf\textcolor{white}{docker}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{p{17.67cm}}{\vspace{1px}\centerline{\includegraphics[width=5.1cm]{/web/www.cheatography.com/public/uploads/christian-knell_1567002032_docker.png}}} \tn \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}{BUILD}} \tn % Row 0 \SetRowColor{LightBackground} `docker build -t IMAGE:TAG` & Build an image from the Dockerfile in the current directory and tag it \tn % Row Count 4 (+ 4) % Row 1 \SetRowColor{white} \{\{ar\}\} `-f \seqsplit{/path/to/dockerfile`} & Define the Dockerfile, which should be used \tn % Row Count 7 (+ 3) % Row 2 \SetRowColor{LightBackground} \{\{ar\}\} `-{}-no-cache` & Force a complete new build from scrath \tn % Row Count 9 (+ 2) % Row 3 \SetRowColor{white} `docker image ls`, `docker images` & List all images that are locally stored within the Docker engine \tn % Row Count 13 (+ 4) % Row 4 \SetRowColor{LightBackground} `docker rmi IMAGE:TAG` & Delete an image from the local image store \tn % Row Count 15 (+ 2) % Row 5 \SetRowColor{white} `docker history IMAGE` & Show the layers of a Docker image \tn % Row Count 17 (+ 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}{SHIP}} \tn % Row 0 \SetRowColor{LightBackground} `docker login \seqsplit{my.registry.com:8000`} & Log in to a registry (the Docker Hub by default) \tn % Row Count 3 (+ 3) % Row 1 \SetRowColor{white} `docker tag IMAGE:TAG \seqsplit{REPOSITORY/IMAGE:TAG`} & Retag a local image with a new image name and tag \tn % Row Count 6 (+ 3) % Row 2 \SetRowColor{LightBackground} `docker push \seqsplit{REPOSITORY/IMAGE:TAG`} & Push an image to a registry \tn % Row Count 8 (+ 2) % Row 3 \SetRowColor{white} `docker pull \seqsplit{REPOSITORY/IMAGE:TAG`} & Pull an image from a registry \tn % Row Count 10 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{x{8.2896 cm} x{8.9804 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{17.67cm}}{\bf\textcolor{white}{RUN}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{2}{x{17.67cm}}{`docker run {[}OPTIONS{]} IMAGE{[}:TAG{]}`} \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} \{\{ar\}\} `-d` & Run container in the background \tn % Row Count 3 (+ 2) % Row 2 \SetRowColor{LightBackground} \{\{ar\}\} `-it` & Connect the container to the current terminal \tn % Row Count 6 (+ 3) % Row 3 \SetRowColor{white} \{\{ar\}\} `-p PUBLISHED:TARGET` & Expost port PUBLISHED externally and map to port TARGET inside the container \tn % Row Count 10 (+ 4) % Row 4 \SetRowColor{LightBackground} \{\{ar\}\} `-{}-name CONTAINERNAME` & Name the container with CONTAINERNAME \tn % Row Count 12 (+ 2) % Row 5 \SetRowColor{white} \{\{ar\}\} `-{}-rm` & Remove the container automatically after it exists \tn % Row Count 15 (+ 3) % Row 6 \SetRowColor{LightBackground} \{\{ar\}\} `-v /PATH/TO/VOLUME` & Create a host mapped volume inside the container \tn % Row Count 18 (+ 3) % Row 7 \SetRowColor{white} \{\{ar\}\} `/bin/bash` & The command to run inside the container \tn % Row Count 20 (+ 2) % Row 8 \SetRowColor{LightBackground} `docker stop CONTAINERNAME` & Stop the running container CONTAINERNAME through SIGTERM \tn % Row Count 23 (+ 3) % Row 9 \SetRowColor{white} `docker kill CONTAINERNAME` & Stop the running container CONTAINERNAME through SIGKILL \tn % Row Count 26 (+ 3) % Row 10 \SetRowColor{LightBackground} `docker logs {[}OPTIONS{]} CONTAINERNAME` & Fetch the logs of a container named CONTAINERNAME \tn % Row Count 29 (+ 3) % Row 11 \SetRowColor{white} \{\{ar\}\} `-{}-details` & Show extra details provided to logs \tn % Row Count 31 (+ 2) \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{x{8.2896 cm} x{8.9804 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{17.67cm}}{\bf\textcolor{white}{RUN (cont)}} \tn % Row 12 \SetRowColor{LightBackground} \{\{ar\}\} `-{}-follow`, `-f` & Follow log output \tn % Row Count 2 (+ 2) % Row 13 \SetRowColor{white} \{\{ar\}\} `-{}-tail LINES` & Number of LINES to show from the end of the logs \tn % Row Count 5 (+ 3) % Row 14 \SetRowColor{LightBackground} \{\{ar\}\} `-{}-timestamps`, `-t` & Show timestamps \tn % Row Count 7 (+ 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}{NETWORK}} \tn % Row 0 \SetRowColor{LightBackground} `docker network ls` & List networks \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} `docker network create {[}OPTIONS{]} NETWORKNAME` & Create a network named NETWORKNAME \tn % Row Count 4 (+ 3) % Row 2 \SetRowColor{LightBackground} \{\{ar\}\} `-{}-driver`, `-d` `(bridge | overlay | macvlan)` & Driver to manage the Network \tn % Row Count 7 (+ 3) % Row 3 \SetRowColor{white} \{\{ar\}\} `-{}-attachable` & Enable manual container attachment \tn % Row Count 9 (+ 2) % Row 4 \SetRowColor{LightBackground} \{\{ar\}\} `-{}-gateway IP\_ADDRESS` & IPv4 or IPv6 Gateway for the master subnet \tn % Row Count 12 (+ 3) % Row 5 \SetRowColor{white} \{\{ar\}\} `-{}-subnet \seqsplit{IP\_ADDRESS/NETWORK`} & Subnet in CIDR format that represents a network segment \tn % Row Count 15 (+ 3) % Row 6 \SetRowColor{LightBackground} `docker network inspect {[}OPTIONS{]} NETWORK {[}NETWORK...{]}` & Display detailed information on one or more networks \tn % Row Count 18 (+ 3) % Row 7 \SetRowColor{white} \{\{ar\}\} `-{}-verbose`, `-v` & Verbose output for diagnostics \tn % Row Count 20 (+ 2) % Row 8 \SetRowColor{LightBackground} `docker network rm NETWORK {[}NETWORK...{]}` & Remove one or more networks \tn % Row Count 22 (+ 2) % Row 9 \SetRowColor{white} `docker network connect {[}OPTIONS{]} NETWORK CONTAINER` & Connect a container to a network \tn % Row Count 25 (+ 3) % Row 10 \SetRowColor{LightBackground} \{\{ar\}\} `-{}-ip IP\_ADDRESS` & IPv4 address (e.g., 172.30.100.104) \tn % Row Count 27 (+ 2) % Row 11 \SetRowColor{white} \{\{ar\}\} `-{}-ip6 IP\_ADDRESS` & IPv6 address (e.g., 2001:db8::33) \tn % Row Count 29 (+ 2) % Row 12 \SetRowColor{LightBackground} `docker network disconnect {[}OPTIONS{]} NETWORK CONTAINER` & Disconnect a container from a network \tn % Row Count 32 (+ 3) \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}{NETWORK (cont)}} \tn % Row 13 \SetRowColor{LightBackground} \{\{ar\}\} `-{}-force`, `-f` & Force the container to disconnect from a network \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}{VOLUMES}} \tn % Row 0 \SetRowColor{LightBackground} `docker volume ls` & List volumes \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} `docker volume create {[}OPTIONS{]} {[}VOLUME{]}` & Create a volume \tn % Row Count 4 (+ 3) % Row 2 \SetRowColor{LightBackground} \{\{ar\}\} `-{}-driver`, `-d` & Specify volume driver name \tn % Row Count 6 (+ 2) % Row 3 \SetRowColor{white} \{\{ar\}\} `-{}-name` & Specify volume name \tn % Row Count 7 (+ 1) % Row 4 \SetRowColor{LightBackground} `docker volume inspect VOLUME {[}VOLUME...{]}` & Display detailed information on one or more volumes \tn % Row Count 10 (+ 3) % Row 5 \SetRowColor{white} `docker volume rm {[}OPTIONS{]} VOLUME {[}VOLUME...{]}` & Remove one or more volumes \tn % Row Count 13 (+ 3) % Row 6 \SetRowColor{LightBackground} \{\{ar\}\} `-{}-force`, `-f` & Force the removal of one or more volumes \tn % Row Count 15 (+ 2) \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}{MANAGE}} \tn % Row 0 \SetRowColor{LightBackground} `docker container ls`, `docker ps` & List all running containers \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} `docker system df` & Show docker disk usage \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} \{\{ar\}\} `-{}-verbose`, `-v` & Show detailed information on space usage \tn % Row Count 6 (+ 2) % Row 3 \SetRowColor{white} `docker system prune {[}OPTIONS{]}` & Remove unused data \tn % Row Count 8 (+ 2) % Row 4 \SetRowColor{LightBackground} \{\{ar\}\} `-{}-all`, `-a` & Remove all unused images not just dangling ones \tn % Row Count 11 (+ 3) % Row 5 \SetRowColor{white} \{\{ar\}\} `-{}-force`, `-f` & Do not prompt for confirmation \tn % Row Count 13 (+ 2) % Row 6 \SetRowColor{LightBackground} \{\{ar\}\} `-{}-volumes` & Prune volumes \tn % Row Count 14 (+ 1) % Row 7 \SetRowColor{white} `docker image prune {[}OPTIONS{]}` & Remove unused images \tn % Row Count 16 (+ 2) % Row 8 \SetRowColor{LightBackground} \{\{ar\}\} `-{}-all`, `-a` & Remove all unused images not just dangling ones \tn % Row Count 19 (+ 3) % Row 9 \SetRowColor{white} \{\{ar\}\} `-{}-force`, `-f` & Do not prompt for confirmation \tn % Row Count 21 (+ 2) % Row 10 \SetRowColor{LightBackground} `docker container prune {[}OPTIONS{]}` & Remove all stopped containers \tn % Row Count 23 (+ 2) % Row 11 \SetRowColor{white} \{\{ar\}\} `-{}-force`, `-f` & Do not prompt for confirmation \tn % Row Count 25 (+ 2) % Row 12 \SetRowColor{LightBackground} `docker volume prune {[}OPTIONS{]}` & Remove all unused local volumes \tn % Row Count 27 (+ 2) % Row 13 \SetRowColor{white} \{\{ar\}\} `-{}-force`, `-f` & Do not prompt for confirmation \tn % Row Count 29 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{17.67cm}}{\bf\textcolor{white}{Page Break}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{17.67cm}}{} \tn % Row Count 0 (+ 0) \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{17.67cm}}{\bf\textcolor{white}{docker-compose}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{p{17.67cm}}{\vspace{1px}\centerline{\includegraphics[width=5.1cm]{/web/www.cheatography.com/public/uploads/christian-knell_1567001626_docker-compose.png}}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{17.67cm}}{\bf\textcolor{white}{docker-compose.yml}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{17.67cm}}{version: '3' \newline \newline services: \newline service1: \newline image: \seqsplit{registry/repository/image:tag} \newline depends\_on: \newline - service2 \newline env\_file: path/to/file \newline environment: \newline - ENV\_VAR=value \newline networks: \newline - network1 \newline ports: \newline - "3000" \newline - "3000-3005" \newline - "8000:8000" \newline - "9090-9091:8080-8081" \newline - "127.0.0.1:8001:8001" \newline - \seqsplit{"127.0.0.1:5000-5010:5000-5010"} \newline - "6060:6060/udp" \newline restart: (no | always | on-failure | unless-stopped) \newline volumes: \newline - /path/in/container ~~~~~~~~~~~~~~~~~~ \# Just specify a path and let the Engine create a volume \newline - \seqsplit{/path/on/host:/path/in/container} ~~~~ \# Specify an absolute path mapping \newline - \seqsplit{./path/on/host:/path/in/container} ~~~ \# Path on the host, relative to the Compose file \newline - \textasciitilde{}/path/on/host:/path/in/container/:ro \# User-relative path \newline - \seqsplit{namedvolume:/path/in/container} ~~~~~~ \# Named volume \newline service2: \newline image: \seqsplit{registry/repository/another\_image:tag} \newline \newline networks: \newline network1: \newline \newline volumes: \newline namedvolume: \newline driver: local \# See \seqsplit{https://docs.docker.com/engine/extend/legacy\_plugins/\#/volume-plugins} for other drivers \newline external: (false | true) \# If true, docker-compose does not attempt to create it} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{17.67cm}}{Komplette File-Reference: \seqsplit{https://docs.docker.com/compose/compose-file}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{x{6.7353 cm} x{10.5347 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{17.67cm}}{\bf\textcolor{white}{Docker-Compose Parameters}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{2}{x{17.67cm}}{`docker-compose {[}options{]} {[}COMMAND{]}`} \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} \{\{ar\}\} `-{}-version`, `-v` & Print version \tn % Row Count 3 (+ 2) % Row 2 \SetRowColor{LightBackground} \{\{ar\}\} `-{}-file`, `-f` & Specify an compose file (default: docker-compose.yml) \tn % Row Count 6 (+ 3) % Row 3 \SetRowColor{white} \{\{ar\}\} `-{}-verbose` & Show more output \tn % Row Count 8 (+ 2) % Row 4 \SetRowColor{LightBackground} \{\{ar\}\} `-{}-log-level LEVEL` & Set log level (DEBUG, INFO, WARNING, ERROR, CRITICAL) \tn % Row Count 11 (+ 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}{Command Overview}} \tn % Row 0 \SetRowColor{LightBackground} `docker-compose up {[}OPTIONS{]}` & Starts all containers \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} \{\{ar\}\} `-{}-detached`, `-d` & detached mode: Run containers in the background \tn % Row Count 5 (+ 3) % Row 2 \SetRowColor{LightBackground} \{\{ar\}\} `-{}-force-recreate` & Recreate containers even if their configuration and image haven't changed \tn % Row Count 9 (+ 4) % Row 3 \SetRowColor{white} \{\{ar\}\} `-{}-remove-orphans` & Remove containers for services not defined in the Compose file \tn % Row Count 13 (+ 4) % Row 4 \SetRowColor{LightBackground} `docker-compose down {[}OPTIONS{]}` & Stops containers and removes containers, networks, volumes, and images created by up \tn % Row Count 18 (+ 5) % Row 5 \SetRowColor{white} \{\{ar\}\} `-{}-volumes`, `-v` & Remove named and anonymous volumes \tn % Row Count 20 (+ 2) % Row 6 \SetRowColor{LightBackground} \{\{ar\}\} `-{}-remove-orphans` & Remove containers for services not defined in the Compose file \tn % Row Count 24 (+ 4) % Row 7 \SetRowColor{white} `docker-compose stop {[}SERVICE{]}` & Stops running containers without removing them \tn % Row Count 27 (+ 3) % Row 8 \SetRowColor{LightBackground} `docker-compose kill {[}SERVICE{]}` & Forces running containers to stop by sending a SIGKILL signal \tn % Row Count 31 (+ 4) \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}{Command Overview (cont)}} \tn % Row 9 \SetRowColor{LightBackground} `docker-compose rm {[}OPTIONS{]} {[}SERVICE...{]}` & Removes stopped service containers \tn % Row Count 3 (+ 3) % Row 10 \SetRowColor{white} \{\{ar\}\} `-{}-force`, `-f` & Don't ask to confirm removal \tn % Row Count 5 (+ 2) % Row 11 \SetRowColor{LightBackground} \{\{ar\}\} `-{}-stop`, `-s` & Stop the containers before removing \tn % Row Count 7 (+ 2) % Row 12 \SetRowColor{white} \{\{ar\}\} `-v` & Remove any anonymous volumes attached to containers \tn % Row Count 10 (+ 3) % Row 13 \SetRowColor{LightBackground} `docker-compose pull SERVICE` & Pulls an image associated with the SERVCE \tn % Row Count 13 (+ 3) % Row 14 \SetRowColor{white} `docker-compose logs SERVICE` & Displays log output from the SERVICE \tn % Row Count 15 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{17.67cm}}{\bf\textcolor{white}{Page Break}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{17.67cm}}{} \tn % Row Count 0 (+ 0) \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{17.67cm}}{\bf\textcolor{white}{Docker Swarm}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{p{17.67cm}}{\vspace{1px}\centerline{\includegraphics[width=5.1cm]{/web/www.cheatography.com/public/uploads/christian-knell_1567001615_docker swarm.png}}} \tn \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}{SWARM AWAY}} \tn % Row 0 \SetRowColor{LightBackground} `docker swarm init` & Initialize swarm mode \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} \{\{ar\}\}`-{}-advertise-addr IP` & listen on a specific interface \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} `docker swarm join-token (worker|manager)` & Create a join token for a worker|manager node \tn % Row Count 7 (+ 3) % Row 3 \SetRowColor{white} `docker swarm join -{}-token \textless{}token\textgreater{} IP:2377` & Join an existing swarm (under IP) as a manager node \tn % Row Count 10 (+ 3) % Row 4 \SetRowColor{LightBackground} `docker node ls` & List the nodes participating in a swarm \tn % Row Count 12 (+ 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}{ORCHESTRATE}} \tn % Row 0 \SetRowColor{LightBackground} `docker service ls` & List the services running in a swarm \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} `docker service ps SERVICENAME` & List the tasks of the SERVICENAME \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} `docker service create {[}OPTIONS{]} IMAGE` & Create a new service \tn % Row Count 6 (+ 2) % Row 3 \SetRowColor{white} \{\{ar\}\} `-{}-replicas NUMBER` & NUMBER of tasks \tn % Row Count 8 (+ 2) % Row 4 \SetRowColor{LightBackground} \{\{ar\}\} `-{}-publish`, `-p` `EXPOSED:TARGET` & Publish a port (TARGET) as a node port (EXPOSED) \tn % Row Count 11 (+ 3) % Row 5 \SetRowColor{white} \{\{ar\}\} `-{}-name SERVICENAME` & Give the service a name called SERVICENAME \tn % Row Count 14 (+ 3) % Row 6 \SetRowColor{LightBackground} `docker service scale SERVICENAME=NUMBER` & Scale the SERVICENAME to NUMBER \tn % Row Count 17 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \end{document}