projects:zibaldone:linux:docker

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
projects:zibaldone:linux:docker [2022/10/25 09:54] – [docker swarm] sscipioniprojects:zibaldone:linux:docker [2023/04/19 08:08] (current) – [docker registry (public)] sscipioni
Line 157: Line 157:
 </code> </code>
  
 +===== multi platform build =====
 +
 +Multi platform build need a docker registry, local or remote (see below)
 +
 +create a docker builder or use existing one
 +<code>
 +NAME=builder1
 +docker buildx use $NAME || docker buildx create --use --name $NAME --driver-opt network=host
 +</code>
 +
 +build from a Dockerfile and push to local registry
 +<code>
 +REGISTRY=localhost:5000
 +docker buildx build --platform=linux/amd64,linux/arm64 -t $REGISTRY/yololab/helloworld --push .
 +</code>
 ===== docker registry (private) ===== ===== docker registry (private) =====
  
Line 183: Line 198:
 reg digest docker.csgalileo.org/charta/httprest reg digest docker.csgalileo.org/charta/httprest
 </code> </code>
 +
 +docker registry on localhost
 +<file yaml docker-compose.yml>
 +services:
 +  registry:
 +    restart: no
 +    image: registry:2
 +    ports:
 +      - 5000:5000
 +    volumes:
 +      - ./data:/var/lib/registry
 +</file>
  
 ===== docker registry (public) ===== ===== docker registry (public) =====
Line 195: Line 222:
 docker push scipioit/trac:1.4.3 docker push scipioit/trac:1.4.3
 </code> </code>
 +
 +===== remote display via ssh =====
 +
 +scenario: connect to remote docker host via ssh and run X11 GUI on client ssh
 +
 +on docker host sshd edit /etc/ssh/sshd_config
 +<code>
 +X11Forwarding yes
 +X11DisplayOffset 10
 +X11UseLocalhost no
 +</code>
 +
 +on docker host create this helper script 
 +<code bash | set-display.sh>
 +XAUTH=/tmp/Xauthority
 +HOSTIP=$(ip -o route get to 8.8.8.8 | sed -n 's/.*src \([0-9.]\+\).*/\1/p')
 +
 +AUTH_COOKIE=$(xauth list ${DISPLAY} | awk '{print $3}')
 +DISPLAY_NUMBER=$(echo $DISPLAY | cut -d. -f1 | cut -d: -f2)
 +export DISPLAY=${HOSTIP}:${DISPLAY_NUMBER}
 +touch $XAUTH
 +xauth -f $XAUTH add ${DISPLAY} MIT-MAGIC-COOKIE-1 ${AUTH_COOKIE}
 +</code>
 +
 +session from client
 +<code bash>
 +ssh -X <hostip>
 +source set-display.sh
 +docker run --rm -e DISPLAY=$DISPLAY -v $XAUTH:/root/.Xauthority  -t beezu/xeyes
 +</code>
 +
 +
 +
 ===== docker swarm ===== ===== docker swarm =====
  
Line 289: Line 349:
 </code> </code>
  
-get stack using a particular network 'web'+drain a node from containers and migrate to others 
 +<code> 
 +docker node update --availability drain <node> 
 + 
 +# re-enable node after maintenance 
 +docker node update --availability active <node> 
 +</code> 
 + 
 +get services using a particular network 'web'
 <code> <code>
 docker network inspect --verbose web | jq '.[].Services | keys[]' docker network inspect --verbose web | jq '.[].Services | keys[]'
 +</code>
 +
 +get ip allocation in docker networks
 +<code>
 +docker run -it --rm -v /var/run/docker.sock:/var/run/docker.sock docker/ip-util-check
 </code> </code>
  
  • projects/zibaldone/linux/docker.1666684485.txt.gz
  • Last modified: 2022/10/25 09:54
  • by sscipioni