Skip to content

Instantly share code, notes, and snippets.

@snhobbs
Last active June 26, 2025 14:37
Show Gist options
  • Select an option

  • Save snhobbs/69c81e65e85129d566b3e9964ef50079 to your computer and use it in GitHub Desktop.

Select an option

Save snhobbs/69c81e65e85129d566b3e9964ef50079 to your computer and use it in GitHub Desktop.

Here's how you can use Docker to keep several version of KiCad on your system and have them run as if they were native.

Setting up the image

I'd like KiCad to appear as if it was natively installed so I change the desfault user from KiCad to my local username, and give that user sudo rights.

FROM kicad/kicad:9.0

ENV DEBIAN_FRONTEND=noninteractive

# Create a non-root user
ARG ORIGINALUSER=kicad
ARG USERNAME=simon
ARG UID=1000
ARG GID=1000

USER root
RUN usermod -l $USERNAME -d /home/$USERNAME -m -s /bin/bash $ORIGINALUSER  \
    && groupmod -n $USERNAME $ORIGINALUSER \
    && apt-get update && apt-get install -y sudo \
    && echo "${USERNAME} ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers

# Set environment variables for the new user
ENV HOME=/home/${USERNAME}
WORKDIR /home/${USERNAME}

USER ${USERNAME}

CMD ["bash"]

Building

docker build -f kicad.Dockerfile --build-arg UID=$(id -u) \
    --build-arg GID=$(id -g) --build-arg USERNAME=$(whoami) -t kicad9 .

Using the image

docker run -it --rm \  
  -e DISPLAY=$DISPLAY \
  -v /tmp/.X11-unix:/tmp/.X11-unix \
  -v ${HOME}:${HOME} \
  --name kicad9 \
  kicad9

I have a shell script in my local path called kicad9 (and kicad8)

#!/bin/sh
docker run --rm \
  -e DISPLAY=$DISPLAY \
  -v /tmp/.X11-unix:/tmp/.X11-unix \
  -v $HOME:$HOME \
  --device /dev/dri \
  --group-add video \
  kicad9 "$@"

Add -it if you want an interactive terminal.

Adding GPU Access

--device /dev/dri
--group-add video

This allows GPU rendering if available so you're not stuck with software only

You can do the same with KiCad 7 and 8 also, just change the base image.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment