2022-03-28 15:03:21 +02:00
#+title : :tools docker
#+subtitle : Yo dawg, I heard you like OSes, so I…
#+created : September 06, 2018
#+since : 21.12.0
2021-10-16 01:29:27 +02:00
* Description :unfold:
This module allows you to manipulate Docker images, containers, and more from
2019-07-30 15:22:19 +03:00
Emacs.
2019-04-30 17:34:40 -03:00
2021-10-16 01:29:27 +02:00
Provides a major ~dockerfile-mode~ to edit =Dockerfiles= . Additional convenience
functions allow images to be built easily.
2019-04-30 17:34:40 -03:00
2021-10-16 01:29:27 +02:00
[[doom-package: ][docker-tramp ]] offers [[https://www.gnu.org/software/tramp/ ][TRAMP ]] support for Docker containers.
2019-04-30 17:34:40 -03:00
2021-10-16 01:29:27 +02:00
** Maintainers
/This module has no dedicated maintainers./ [[doom-contrib-maintainer: ][Become a maintainer? ]]
2019-04-30 17:34:40 -03:00
2021-10-16 01:29:27 +02:00
** Module flags
- +lsp ::
Enable integration for the Dockerfile Language Server.
2019-04-30 17:34:40 -03:00
2021-10-16 01:29:27 +02:00
** Packages
- [[doom-package: ][docker ]]
- [[doom-package: ][docker-tramp ]]
- [[doom-package: ][dockerfile-mode ]]
** Hacks
/No hacks documented for this module./
** TODO Changelog
# This section will be machine generated. Don't edit it by hand.
/This module does not have a changelog yet./
* Installation
[[id:01cffea4-3329-45e2-a892-95a384ab2338 ][Enable this module in your ~doom!~ block. ]]
This module assumes =docker= , =docker-compose= and =docker-machine= binaries are
installed and accessible from your PATH.
2019-04-30 17:34:40 -03:00
2020-02-09 18:47:05 +09:00
Optionally, this module also uses the following programs:
2021-10-16 01:29:27 +02:00
- =docker-langserver= (for LSP users): ~$ npm install -g
dockerfile-language-server-nodejs~
2020-02-09 18:47:05 +09:00
2021-10-16 01:29:27 +02:00
* TODO Usage
#+begin_quote
🔨 /This module's usage documentation is incomplete./ [[doom-contrib-module: ][Complete it? ]]
#+end_quote
2020-02-09 18:47:05 +09:00
2019-04-30 17:34:40 -03:00
** Docker control
2021-10-16 01:29:27 +02:00
Use ~M-x docker~ , select a resource, and then mark or unmark items using the
2019-07-30 15:22:19 +03:00
following keybindings (for more marking possibilities, check out
2021-10-16 01:29:27 +02:00
[[github:politza/tablist ][politza/tablist ]]):
2019-04-30 17:34:40 -03:00
| Binding | Description |
|-----------+----------------------|
2021-10-16 01:29:27 +02:00
| [[kbd:][?]] | List actions |
| [[kbd:][l]] | Configure listing |
| [[kbd:][m]] | Mark item |
| [[kbd:][u]] | Unmark item |
| [[kbd:][t]] | Toggle marks |
| [[kbd:][U]] | Unmark all |
| [[kbd:][s]] | Sort |
| [[kbd:][* r]] | Mark items by regexp |
| [[kbd:][<]] | Shrink column |
| [[kbd:][>]] | Enlarge column |
| [[kbd:][C-c C-e]] | Export to csv |
2019-04-30 17:34:40 -03:00
*** Supported commands
2021-10-16 01:29:27 +02:00
- ~docker container~ : ~attach~ , ~cp~ , ~diff~ , ~inspect~ , ~kill~ , ~logs~ ,
~pause~ , ~rename~ , ~restart~ , ~rm~ , ~start~ , ~stop~ , ~unpause~
- ~docker image~ : ~inspect~ , ~pull~ , ~push~ , ~rm~ , ~run~ , ~tag~
- ~docker network~ : ~rm~
- ~docker volume~ : ~rm~
- ~docker-machine~ : ~create~ , ~env~ , ~restart~ , ~rm~ , ~start~ , ~stop~
- ~docker-compose~ : ~build~ , ~config~ , ~create~ , ~down~ , ~exec~ , ~logs~ , ~pull~ ,
~push~ , ~remove~ , ~restart~ , ~run~ , ~start~ , ~stop~ , ~up~
2019-04-30 17:34:40 -03:00
2019-07-30 15:22:19 +03:00
You can also enter =dired= or open a file inside a container or volume.
2019-04-30 17:34:40 -03:00
** TRAMP
2021-10-16 01:29:27 +02:00
Offers the [[https://www.gnu.org/software/tramp/ ][TRAMP ]] method =docker= to access running containers:
2022-03-28 15:03:21 +02:00
#+begin_example
2021-10-16 01:29:27 +02:00
C-x C-f /docker:$USER@$CONTAINER:/path/to/file
2022-03-28 15:03:21 +02:00
#+end_example
2019-04-30 17:34:40 -03:00
2021-10-16 01:29:27 +02:00
| =$USER= | the user that you want to use (optional) |
| =$CONTAINER= | the id or name of the container |
* TODO Configuration
#+begin_quote
🔨 /This module's configuration documentation is incomplete./ [[doom-contrib-module: ][Complete it? ]]
#+end_quote
2019-04-30 17:34:40 -03:00
** Popups
2019-07-30 15:22:19 +03:00
Thanks to [[https://github.com/magit/magit-popup ][magit-popup ]], all the popups default arguments can be customized. For
example, here is how to customize the arguments for =docker-image-run-popup= :
2021-10-16 01:29:27 +02:00
#+begin_src emacs-lisp
2019-04-30 17:34:40 -03:00
(setq docker-image-run-arguments '("-i" "-t" "--rm"))
2021-10-16 01:29:27 +02:00
#+end_src
2019-04-30 17:34:40 -03:00
2019-07-30 15:22:19 +03:00
or inside a =use-package= declaration:
2021-10-16 01:29:27 +02:00
#+begin_src emacs-lisp
2019-07-30 15:22:19 +03:00
(use-package! docker
2019-04-30 17:34:40 -03:00
:bind ("C-c d" . docker)
:custom (docker-image-run-arguments '("-i" "-t" "--rm")))
2021-10-16 01:29:27 +02:00
#+end_src
2019-04-30 17:34:40 -03:00
2019-07-30 15:22:19 +03:00
*** Other useful variables
| Variable | Description | Default |
|-------------------------------------+---------------------------------------+------------------|
2021-10-16 01:29:27 +02:00
| ~docker-command~ | The docker binary to use | ~docker~ |
| ~docker-container-default-sort-key~ | Sort key for docker containers | ~("Image")~ |
| ~docker-container-shell-file-name~ | Shell to use when entering containers | ~/bin/bash~ |
| ~docker-image-default-sort-key~ | Sort key for docker images | ~("Repository")~ |
| ~docker-machine-default-sort-key~ | Sort key for docker machines | ~("Name")~ |
| ~docker-network-default-sort-key~ | Sort key for docker networks | ~("Name")~ |
| ~docker-run-as-root~ | Run docker as root | ~nil~ |
| ~docker-volume-default-sort-key~ | Sort key for docker volumes | ~("Driver")~ |
2019-07-30 15:22:19 +03:00
** Completion in Dockerfiles
2021-10-16 01:29:27 +02:00
By default, the keyword completion function detects the =docker-compose= version
of the current buffer and suggests the appropriate keywords.
2019-07-30 15:22:19 +03:00
You can change the candidates offered by the backend by customizing
=docker-compose-keywords= .
2019-04-30 17:34:40 -03:00
* Troubleshooting
2021-10-16 01:29:27 +02:00
[[doom-report: ][Report an issue? ]]
2019-04-30 17:34:40 -03:00
** Tramp hangs on Alpine container
2019-07-30 15:22:19 +03:00
Busyboxes built with the =ENABLE_FEATURE_EDITING_ASK_TERMINAL= config option
also send escape sequences, which =tramp-wait-for-output= doesn't ignore
correctly. This was [[http://git.savannah.gnu.org/cgit/tramp.git/commit/?id=98a511248a9405848ed44de48a565b0b725af82c ][fixed in TRAMP upstream ]] and is available since TRAMP 2.3.
2019-04-30 17:34:40 -03:00
2019-07-30 15:22:19 +03:00
For older versions of TRAMP you can dump [[https://github.com/emacs-pe/docker-tramp.el/blob/master/docker-tramp-compat.el ][docker-tramp-compat.el ]] in your
2021-10-16 01:29:27 +02:00
~load-path~ somewhere and add the following to =$DOOMDIR/config.el= to overwrite
~tramp-wait-for-output~ with the patch applied:
#+begin_src emacs-lisp
(after! tramp
(require 'docker-tramp-compat))
#+end_src
* Frequently asked questions
/This module has no FAQs yet./ [[doom-suggest-faq: ][Ask one? ]]
* TODO Appendix
#+begin_quote
🔨 This module has no appendix yet. [[doom-contrib-module: ][Write one? ]]
#+end_quote