Set up docker-langserver LSP integration and install all Dockerfile tools required by the hooks in this project.
Install docker-langserver LSP and hadolint for Dockerfile development. Use this to enable IDE features and linting before working with Dockerfiles in your project.
/plugin marketplace add zircote/dockerfile-lsp/plugin install dockerfile-lsp@zircote-lspSet up docker-langserver LSP integration and install all Dockerfile tools required by the hooks in this project.
| Tool | Version | Notes |
|---|---|---|
| docker-langserver | 0.11.0+ | LSP server (via npm) |
| hadolint | 2.12.0+ | Dockerfile linter |
| docker | 24.0+ | Container runtime (23.0+ for --check) |
Execute the following setup steps in order:
Check that Docker is installed:
docker --version
If not installed, guide the user to https://docs.docker.com/get-docker/ or use:
# macOS (Homebrew)
brew install --cask docker
# Linux (Ubuntu/Debian)
curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh
# Start Docker daemon (Linux)
sudo systemctl start docker
sudo systemctl enable docker
Check if docker-langserver is available:
which docker-langserver || echo "docker-langserver not found"
Install docker-langserver:
# npm (global install)
npm install -g dockerfile-language-server-nodejs
# Verify installation
docker-langserver --version
Check if hadolint is available:
which hadolint || echo "hadolint not found"
Install hadolint:
# macOS (Homebrew)
brew install hadolint
# Linux (download binary)
HADOLINT_VERSION=$(curl -s https://api.github.com/repos/hadolint/hadolint/releases/latest | grep -oP '"tag_name": "\K(.*)(?=")')
wget -qO /usr/local/bin/hadolint "https://github.com/hadolint/hadolint/releases/download/${HADOLINT_VERSION}/hadolint-Linux-x86_64"
chmod +x /usr/local/bin/hadolint
# Windows (Scoop)
scoop install hadolint
# Docker (run as container)
docker pull hadolint/hadolint
Check that .lsp.json exists and is properly configured:
cat .lsp.json
Expected configuration:
{
"dockerfile": {
"command": "docker-langserver",
"args": ["--stdio"],
"extensionToLanguage": {
"Dockerfile": "dockerfile",
".dockerfile": "dockerfile"
},
"transport": "stdio"
}
}
Confirm hooks are loaded:
cat hooks/hooks.json | head -20
cat hooks/scripts/dockerfile-hooks.sh | head -20
Run hadolint on the sample Dockerfile:
hadolint tests/Dockerfile
Expected output: hadolint suggestions or no output if the file follows best practices.
Create a project-specific hadolint configuration:
cat > .hadolint.yaml << 'EOF'
# Hadolint configuration
# See: https://github.com/hadolint/hadolint#configure
# Ignore specific rules
ignored:
# Uncomment rules to ignore
# - DL3006 # Always tag the version of an image explicitly
# - DL3018 # Pin versions in apk add
# Trusted container registries
trustedRegistries:
- docker.io
- gcr.io
- ghcr.io
# Override rule severity
override:
error:
- DL3001 # Switch to absolute WORKDIR
warning:
- DL3042 # Avoid cache directory with pip install
info:
- DL3032 # yum clean all after yum install
# Label schema (if using labels)
label-schema:
author: text
version: semver
EOF
| Tool | Purpose | Hook |
|---|---|---|
docker-langserver | LSP server for IDE features | Core |
hadolint | Dockerfile linting | hadolint |
docker | Syntax validation | docker-build-check |
docker-langserver --versioncat .lsp.json/opt/homebrew/bin or /usr/local/bin is in PATH/usr/local/bin is in PATHwhich hadolint to confirm locationdocker infodocker --version (need 23.0+)docker build --check -f Dockerfile .--check flag is optional, hooks will continue without itDockerfile, Dockerfile.*, *.dockerfilechmod +x hooks/scripts/dockerfile-hooks.shcat hooks/scripts/dockerfile-hooks.sh | bashIf npm install -g fails with permission errors:
# Option 1: Use nvm (recommended)
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
nvm install --lts
npm install -g dockerfile-language-server-nodejs
# Option 2: Change npm default directory
mkdir ~/.npm-global
npm config set prefix '~/.npm-global'
echo 'export PATH=~/.npm-global/bin:$PATH' >> ~/.bashrc
source ~/.bashrc
npm install -g dockerfile-language-server-nodejs
One-liner to install everything:
npm install -g dockerfile-language-server-nodejs && \
brew install hadolint
# docker-langserver
npm install -g dockerfile-language-server-nodejs
# hadolint
HADOLINT_VERSION=$(curl -s https://api.github.com/repos/hadolint/hadolint/releases/latest | grep -oP '"tag_name": "\K(.*)(?=")')
sudo wget -qO /usr/local/bin/hadolint "https://github.com/hadolint/hadolint/releases/download/${HADOLINT_VERSION}/hadolint-Linux-x86_64"
sudo chmod +x /usr/local/bin/hadolint
# Verify
docker-langserver --version
hadolint --version
After running these commands, provide a status summary showing which tools were installed successfully and any that failed.