Skip to content

Commit

Permalink
allow docker-in-docker
Browse files Browse the repository at this point in the history
  • Loading branch information
jesseduffield committed Nov 14, 2022
1 parent a844e82 commit de33ba9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 18 deletions.
18 changes: 11 additions & 7 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
# adapted from https://github.com/devcontainers/images/blob/main/src/go/.devcontainer/Dockerfile
# adapted from https://medium.com/@toonsev/dev-containers-isolate-your-visual-studio-code-workspaces-a2fed6c60606

# [Choice] Go version (use -bullseye variants on local arm64/Apple Silicon): 1, 1.19, 1.18, 1-bullseye, 1.19-bullseye, 1.18-bullseye, 1-buster, 1.19-buster, 1.18-buster
ARG VARIANT=1-bullseye
FROM golang:${VARIANT}
FROM docker:20.10-dind-rootless
# Go into root
USER root
# Install your dependencies, this can be changed
RUN apk add git bash curl make vim go

RUN go install mvdan.cc/gofumpt@latest
ENV PATH="/root/go/bin:${PATH}"
RUN curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.50.0
RUN golangci-lint --version

# [Optional] Uncomment this section to install additional OS packages.
# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
# && apt-get -y install --no-install-recommends <your-package-list-here>
# Set the user back to the rootless user
USER rootless
# Setup docker
ENV DOCKER_HOST=unix:///var/run/user/1000/docker.sock
15 changes: 4 additions & 11 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,7 @@
"overrideFeatureInstallOrder": [
"ghcr.io/devcontainers/features/common-utils"
],
// not sure if we actually need these
"runArgs": [
"--cap-add=SYS_PTRACE",
"--security-opt",
"seccomp=unconfined"
],
"runArgs": [ "--privileged" ],
// Configure tool-specific properties.
"customizations": {
// Configure properties specific to VS Code.
Expand All @@ -37,7 +32,7 @@
"settings": {
"go.toolsManagement.checkForUpdates": "local",
"go.useLanguageServer": true,
"go.gopath": "/go",
"go.gopath": "~/go",
"[go]": {
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
Expand All @@ -57,12 +52,10 @@
]
}
},
// Use 'postCreateCommand' to run commands after the container is created.
// "postCreateCommand": "go version",

// See https://www.kenmuse.com/blog/avoiding-dubious-ownership-in-dev-containers/ for the safe.directory part
"postStartCommand": "git config --global --add safe.directory ${containerWorkspaceFolder}",

// Set `remoteUser` to `root` to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
"remoteUser": "vscode"
"postCreateCommand": "dockerd-entrypoint.sh --experimental &",
"remoteUser": "rootless"
}

0 comments on commit de33ba9

Please sign in to comment.