lwc:docker

This is an old revision of the document!


# First time setup:
docker-compose build    # Builds your custom image from Dockerfile
docker-compose up -d    # Starts containers using your custom image

# If you change the Dockerfile later:
docker-compose build    # Rebuild the image
docker-compose up -d    # Recreate containers with new image

# Or do both at once:
docker-compose up -d --build
  • copy files to docker container: docker cp foo.txt container_id:/foo.txt
  • copy files from docker container: docker cp container_id:/foot.txt foo.txt
  • prune unneeded files (save disk space): sudo docker system prune -a -f
  • docker system df: show overall space usage by category
  • docker inspect $(docker ps -q) | grep -A 10 Mounts: see what volume goes with what container
  • docker inspect CONTAINER_NAME --format '{{range .Mounts}}{{.Name}} -> {{.Destination}}{{println}}{{end}}' : list what volume is associated with the container
  • docker ps: list docker containers
  • When removing a service use docker compose down -v instead of docker compose down.
    • The -v removes the associated volumes at the same time.
  • When updating images, after pulling and restarting, run docker image prune to remove the dangling images
  • Watchtower is a container which auto updates Docker containers
  • It will only update containers with updates that have the same tag
    • to always get the latest version use the tag latest
    • you can check which images have which tags with docker images
      • some images might have latest but not be base images so they won't be updated
  • check the logs: docker logs watchtower
  • if you want Watchtower to skip trying to update an image add to docker-compose.yml
 services:
  db:
    # label the image as each image gets its own label
    image: mariadb:latest # an example
    labels:
      - "com.centurylinklabs.watchtower.enable=false" # ADD THIS LINE
  • lwc/docker.1772305190.txt.gz
  • Last modified: 2026/02/28 12:59
  • by John Harrison