2016-06-10 03:53:33 +00:00
|
|
|
#+TITLE: Docker layer
|
2015-11-08 10:38:23 +00:00
|
|
|
|
2019-05-02 21:49:30 +00:00
|
|
|
#+TAGS: layer|tool
|
|
|
|
|
2015-11-08 10:38:23 +00:00
|
|
|
[[file:img/docker.png]]
|
|
|
|
|
2019-05-07 20:05:06 +00:00
|
|
|
* Table of Contents :TOC_5_gh:noexport:
|
2017-05-22 14:16:12 +00:00
|
|
|
- [[#description][Description]]
|
2018-01-26 20:42:41 +00:00
|
|
|
- [[#features][Features:]]
|
2017-05-22 14:16:12 +00:00
|
|
|
- [[#install][Install]]
|
2019-11-10 05:53:44 +00:00
|
|
|
- [[#docker][Docker]]
|
|
|
|
- [[#linting][Linting]]
|
|
|
|
- [[#lsp][LSP]]
|
2017-05-22 14:16:12 +00:00
|
|
|
- [[#usage][Usage]]
|
|
|
|
- [[#tramp-access-to-docker-containers][TRAMP access to docker containers]]
|
|
|
|
- [[#key-bindings][Key bindings]]
|
2015-11-08 10:38:23 +00:00
|
|
|
|
|
|
|
* Description
|
2018-01-26 20:42:41 +00:00
|
|
|
This layer integrates basic container management into Spacemacs.
|
2015-11-08 10:38:23 +00:00
|
|
|
|
2018-01-26 20:42:41 +00:00
|
|
|
** Features:
|
|
|
|
- Syntax highlighting for =Docker= files
|
|
|
|
- =Docker= build integration
|
|
|
|
- =TRAMP= access to running Docker containers
|
|
|
|
- =Docker= container and image management via [[https://github.com/Silex/docker.el][docker.el]]
|
2018-09-21 09:53:13 +00:00
|
|
|
- =docker-compose= integration via [[https://github.com/Silex/docker.el][docker.el]]
|
2018-01-26 20:42:41 +00:00
|
|
|
- Syntax checking via [[https://github.com/hadolint/hadolint][hadolint]]
|
2020-04-02 16:41:28 +00:00
|
|
|
- Code-Completion via =lsp=
|
2015-11-08 10:38:23 +00:00
|
|
|
|
|
|
|
* Install
|
2019-11-10 05:53:44 +00:00
|
|
|
** Docker
|
2016-06-10 03:46:10 +00:00
|
|
|
To use this configuration layer, add it to your =~/.spacemacs=. You will need to
|
|
|
|
add =docker= to the existing =dotspacemacs-configuration-layers= list in this
|
|
|
|
file.
|
2015-11-08 10:38:23 +00:00
|
|
|
|
2018-01-26 20:42:41 +00:00
|
|
|
You will also need the native package [[https://www.docker.com/][Docker]] for the actual container management.
|
2019-11-10 05:53:44 +00:00
|
|
|
|
|
|
|
** Linting
|
|
|
|
For syntax checking the external library [[https://github.com/hadolint/hadolint][hadolint]] is necessary.
|
2019-12-01 01:03:30 +00:00
|
|
|
It can either be downloaded from [[https://github.com/hadolint/hadolint/releases/latest][=here=]] or
|
|
|
|
build locally with stack as shown below:
|
2019-12-03 20:31:20 +00:00
|
|
|
|
2019-12-01 01:03:30 +00:00
|
|
|
#+BEGIN_SRC sh
|
|
|
|
stack install hadolint
|
|
|
|
#+END_SRC
|
2019-11-10 05:53:44 +00:00
|
|
|
|
|
|
|
** LSP
|
2019-12-01 01:03:30 +00:00
|
|
|
This layer can be enhanced with [[https://github.com/rcjsuen/dockerfile-language-server-nodejs][=dockerfile-language-server-nodejs=]] and emacs
|
2019-11-10 05:53:44 +00:00
|
|
|
[[https://github.com/emacs-lsp/lsp-mode][=lsp-mode=]] to provide richer, IDE-like capabilities.
|
2019-12-01 01:03:30 +00:00
|
|
|
To do so set the layer variable =docker-dockerfile-backend= to =lsp= like shown below:
|
2019-12-03 20:31:20 +00:00
|
|
|
|
2019-11-10 05:53:44 +00:00
|
|
|
#+BEGIN_SRC emacs-lisp
|
|
|
|
(setq-default dotspacemacs-configuration-layers
|
|
|
|
'((docker :variables docker-dockerfile-backend 'lsp)))
|
|
|
|
#+END_SRC
|
2018-01-26 20:42:41 +00:00
|
|
|
|
2019-12-01 01:03:30 +00:00
|
|
|
In addition you need to install the lsp server's executable in your system.
|
|
|
|
This can be done via npm:
|
2019-12-03 20:31:20 +00:00
|
|
|
|
2019-12-01 01:03:30 +00:00
|
|
|
#+BEGIN_SRC sh
|
|
|
|
npm i -g dockerfile-language-server-nodejs
|
|
|
|
#+END_SRC
|
|
|
|
|
2016-06-10 03:53:33 +00:00
|
|
|
* Usage
|
2016-06-10 03:46:10 +00:00
|
|
|
** TRAMP access to docker containers
|
2016-11-22 20:53:50 +00:00
|
|
|
This relies on the [[https://github.com/emacs-pe/docker-tramp.el][docker-tramp]] package which uses =docker exec= available in
|
2016-06-10 03:46:10 +00:00
|
|
|
docker versions > 1.3.
|
2015-11-08 10:38:23 +00:00
|
|
|
|
2016-06-10 03:46:10 +00:00
|
|
|
=docker-tramp= adds a new prefix =/docker:= that you can use with ~SPC f f~,
|
2018-01-26 20:42:41 +00:00
|
|
|
this prefix allows to access your docker containers and also provides
|
2016-06-10 03:46:10 +00:00
|
|
|
auto-completion of the running containers.
|
2015-11-08 10:38:23 +00:00
|
|
|
|
|
|
|
* Key bindings
|
|
|
|
|
2020-06-21 22:04:52 +00:00
|
|
|
| Key binding | Description |
|
|
|
|
|---------------+---------------------------------------------|
|
|
|
|
| ~SPC m c b~ | build current buffer |
|
|
|
|
| ~SPC m c B~ | build current buffer without cache |
|
|
|
|
| ~SPC a t d c~ | list docker containers |
|
|
|
|
| ~SPC a t d C~ | docker-compose commands for current project |
|
|
|
|
| ~SPC a t d d~ | delete image |
|
|
|
|
| ~SPC a t d e~ | unpause container |
|
|
|
|
| ~SPC a t d F~ | pull image |
|
|
|
|
| ~SPC a t d i~ | list docker images |
|
|
|
|
| ~SPC a t d k~ | delete container |
|
|
|
|
| ~SPC a t d o~ | stop container |
|
|
|
|
| ~SPC a t d p~ | pause container |
|
|
|
|
| ~SPC a t d P~ | push image |
|
|
|
|
| ~SPC a t d r~ | restart container |
|
|
|
|
| ~SPC a t d s~ | start container |
|