Pin Loon's Wiki
  • Welcome to my technical notes
  • About Me
  • Linux
    • Basic commands
    • Controller Area Network (CAN)
    • Disk
    • Ethernet
    • Systemd Service
    • SSH
  • Microcontroller / Single Board Computer
    • Debugger / Compiler
    • Raspberry Pi 4
  • Application Platform
    • Docker
    • Docker Compose
  • Application Notes
    • Dataype Overflow
    • Macros
    • Wrong Casting
    • Variadic Function
  • Git
    • Create SSH Keys
    • Git submodule
  • VPN
    • Wireguard Setup on Azure
Powered by GitBook
On this page
  • Building docker image
  • Running inside docker container
  • Example of script with display enabled
  • Remove docker images by force
  • Remove all container, network, cache and image
  1. Application Platform

Docker

Building docker image

$ sudo docker build . -t <reponame>:<tagname> -f <Dockerfile>

Running inside docker container

$ sudo docker run -it --name <name of container> <reponame>:<tagname>

Example of script with display enabled

xhost local:root
XAUTH=/tmp/.docker.xauth

docker run -it --rm \
    --name=<docker container> \
    --env="DISPLAY=$DISPLAY" \
    --env="QT_X11_NO_NITSHM=1" \
    --volume="/tmp/.X11-unix/:/tmp/.X11-unix:rw" \
    --env="XAUTHORITY=$XAUTH"\
    --volume="$XAUTH:$XAUTH" \
    --net=host \
    --privileged \
    <docker image>

Remove docker images by force

$ sudo docker rmi -f <docker image id>

Remove all container, network, cache and image

$ sudo docker system prune -a
PreviousRaspberry Pi 4NextDocker Compose

Last updated 9 months ago