# 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
docker cp foo.txt container_id:/foo.txtdocker cp container_id:/foot.txt foo.txtsudo docker system prune -a -fdocker system df: show overall space usage by categorydocker inspect $(docker ps -q) | grep -A 10 Mounts: see what volume goes with what containerdocker inspect CONTAINER_NAME --format '{{range .Mounts}}{{.Name}} -> {{.Destination}}{{println}}{{end}}' : list what volume is associated with the containerdocker ps: list docker containersdocker compose down -v instead of docker compose down.-v removes the associated volumes at the same time.docker image prune to remove the dangling imagesdocker ps -a: see all containers, even the ones that are stoppedlatestdocker imageslatest but not be base images so they won't be updateddocker logs watchtowerdocker-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
docker run --rm -v /var/run/docker.sock:/var/run/docker.sock containrrr/watchtower --run-oncedocker run: run container-d flag for “detach” i.e. run in background-p flag to forward the port i.e. -p 9000:80 maps port 80 in the container to 9000 on the host--name flag to name the container (otherwise it's auto generated)docker stop <ID>docker logs <ID>docker start <ID>: restart a containerdocker build <DIR_WHERE_Dockerfile_IS_LOCATED>: build the image-t: add name and tag. Ex: docker build -t node-app:1.0 .FROMCOPYCOPY package.json /app/WORKDIRWORKDIR /appRUN <dependencies here>RUN npm installCMDCMD ["node", "server.js"]