User Tools

Site Tools


linux:docker

Differences

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

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
linux:docker [2023/06/04 13:07] Wulf Rajeklinux:docker [2025/04/16 23:45] (current) Wulf Rajek
Line 2: Line 2:
  
 https://docs.docker.com/storage/volumes/ https://docs.docker.com/storage/volumes/
 +
 +===== Main install =====
 +<code>
 +apt-get -y install curl unzip dialog
 +curl -fSSL get.docker.com | sh
 +</code>
 +
 +===== Show logs =====
 +
 +<code>
 +docker logs --follow <containername>
 +</code>
 +
 +
 +===== Build image =====
 +
 +To build the docker image based on a Dockerfile in the current directory, use:
 +<code>
 +docker build .
 +</code>
 +
 +===== Update container =====
  
 Update docker container to latest version via docker compose: Update docker container to latest version via docker compose:
Line 15: Line 37:
 docker image prune docker image prune
 </code> </code>
 +
 +===== Health Checks =====
  
 Docker compose health checks: Docker compose health checks:
 https://medium.com/geekculture/how-to-successfully-implement-a-healthcheck-in-docker-compose-efced60bc08e https://medium.com/geekculture/how-to-successfully-implement-a-healthcheck-in-docker-compose-efced60bc08e
  
-Copying files from/to images+https://stefanjarina.gitbooks.io/docker/content/swarm-mode/healthchecks.html 
 +===== Copying files to/from containers ===== 
 + 
 +Copying files from/to containers
 <code> <code>
 docker cp dockerimage:/bla ./bla docker cp dockerimage:/bla ./bla
Line 25: Line 52:
 </code> </code>
  
 +===== Flatten docker image layers =====
 +Flatten docker image layers:
 +<code>
 +FROM yourbuildimage as build
 +# your existing build steps here
 +FROM scratch
 +COPY --from=build / /
 +CMD ["/your/start/script"]
 +</code>
 +
 +===== Change mount points of containers =====
 Change mount points of existing docker containers; Change mount points of existing docker containers;
  
Line 59: Line 97:
   - Start the container if necessary: <code>docker start <container-name/ID></code>   - Start the container if necessary: <code>docker start <container-name/ID></code>
  
 +
 +===== PHP&NGINX image =====
  
 Containerised PHP & NGINX on Alpine, image size ~60MB: Containerised PHP & NGINX on Alpine, image size ~60MB:
 https://levelup.gitconnected.com/containerizing-nginx-php-fpm-on-alpine-linux-953430ea6dbc https://levelup.gitconnected.com/containerizing-nginx-php-fpm-on-alpine-linux-953430ea6dbc
 https://github.com/johnathanesanders/docker-nginx-fpm https://github.com/johnathanesanders/docker-nginx-fpm
 +
 +Log nginx to stdout in Dockerfile:
 +<code>
 +# forward request and error logs to docker log collector
 +RUN ln -sf /dev/stdout /var/log/nginx/access.log \
 + && ln -sf /dev/stderr /var/log/nginx/error.log
 +</code>
 +
 +===== Rename/Retag image files =====
 +
 +<code>
 +docker tag current/image:tag new/image:tag
 +</code>
 +
 +===== cmd shell of container =====
 +<code>
 +docker exec -it <mycontainer> bash
 +docker exec -it <mycontainer> /bin/sh
 +</code>
 +
 +===== GPU hardware acceleration =====
 +
 +Make sure the relevant GPU drivers are installed on the base system, then pass through the device via docker compose.
 +Check devices are available, there should be a device per GPU starting at renderD128 for the first GPU:
 +<code>
 +ls -la /dev/dri
 +</code>
 +
 +<code>
 +  devices:
 +   - /dev/dri:/dev/dri
 +</code>
 +
 +===== docker ps short =====
 +Short form of docker ps to only get the container names:
 +<code>
 +docker ps | sed 's/   */#/g' | cut -d "#" -f 7
 +</code>
 +
 +===== docker running out of network addresses =====
 +
 +Error response from daemon: all predefined address pools have been fully subnetted 
 +
 +<code json /etc/docker/daemon.json>
 +{
 +"default-address-pools":[
 +    {"base":"169.254.2.0/23","size":28},
 +    {"base":"169.254.4.0/22","size":28},
 +    {"base":"169.254.8.0/21","size":28},
 +    {"base":"169.254.16.0/20","size":28},
 +    {"base":"169.254.32.0/19","size":28},
 +    {"base":"169.254.64.0/18","size":28},
 +    {"base":"169.254.128.0/18","size":28},
 +    {"base":"169.254.192.0/19","size":28},
 +    {"base":"169.254.224.0/20","size":28},
 +    {"base":"169.254.240.0/21","size":28},
 +    {"base":"169.254.248.0/22","size":28}
 +  ]
 +}
 +</code>
 +<code>
 +docker restart
 +docker network prune
 +</code>
  
linux/docker.1685880470.txt.gz · Last modified: 2023/06/04 13:07 by Wulf Rajek